Cod sursa(job #125191)
Utilizator | Ada-Mihaela Solcan ada_s | Data | 20 ianuarie 2008 11:58:34 |
---|---|---|---|
Problema | Gardieni | Scor | 20 |
Compilator | cpp | Status | done |
Runda | preONI 2008, Runda 3, Clasa a 10-a | Marime | 0.42 kb |
#include <fstream>
std::ifstream f1("gardieni.in");
std::ofstream f2("gardieni.out");
int main()
{
long cost[50010], i, j, a, b, c, n, t;
unsigned long long s, u;
f1>>n>>t;
for (i=0; i<n; i++)
{
f1>>a>>b>>c;
for (j=a; j<=b; j++)
if ((cost[j]==0)||(cost[j]>c))
cost[j]=c;
}//for i
for (i=1; i<=t; i++)
{
//f2<<cost[i]<<" ";
u=cost[i];
s+=u;
}//for i
f2<<s;
f1.close();
f2.close();
return 0;
}//main