Cod sursa(job #291042)
Utilizator | Data | 29 martie 2009 12:02:04 | |
---|---|---|---|
Problema | Gardieni | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.34 kb |
#include<fstream.h>
long long int x[1000000],s,n,t,a,b,c;
ifstream in("gardieni.in");
ofstream out("gardieni.out");
int main()
{ long long int i,j;
in>>n>>t;
for(j=1;j<=n;j++)
{ in>>a>>b>>c;
for(i=a;i<=b;i++)
if((c<x[i])||(x[i]==0))x[i]=c;
}
for(i=1;i<=t;i++)
s=s+x[i];
out<<s;
in.close();
out.close();
return 0;
}