Pagini recente » Istoria paginii runda/oji_2009_10/clasament | template/implica-te/scrie-articole-2 | Cod sursa (job #2880056) | Cod sursa (job #1057914) | Cod sursa (job #1743987)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("gardieni.in");
ofstream cout("gardieni.out");
const int INF = 1000000000;
const int MAXT = 1000000;
int best[1 + MAXT];
int main() {
int n, t;
cin >> n >> t;
for (int i = 1; i <= t; i++)
best[i] = INF;
for (int i = 1; i <= n; i++) {
int a, b, c;
cin >> a >> b >> c;
for (int j = a; j <= b; j++)
best[j] = min(best[j], c);
}
long long answer = 0;
for (int i = 1; i <= t; i++)
answer += best[i];
cout << answer << "\n";
return 0;
}