Pagini recente » Cod sursa (job #1125777) | Cod sursa (job #686782) | Cod sursa (job #2688604) | Cod sursa (job #379859) | Cod sursa (job #1404242)
#include <fstream>
#include <algorithm>
#define INF (1 << 21)
#define DIM 1000001
using namespace std;
ifstream fin("gardieni.in");
ofstream fout("gardieni.out");
int n, t;
int dp[DIM];
int main() {
fin >> n >> t;
for (int i = 1; i <= t; i++)
dp[i] = INF;
for (int i = 1; i <= n; i++) {
int x, y, cost;
fin >> x >> y >> cost;
for (int j = x; j <= y; j++)
dp[j] = min(dp[j], cost);
}
long long result = 0;
for (int i = 1; i <= t; i++)
result += dp[i];
fout << result << "\n";
return 0;
}
//Trust me, I'm the Doctor!
//Miriam e tare!