Pagini recente » Cod sursa (job #2329199) | Cod sursa (job #777108) | Cod sursa (job #1757213) | Cod sursa (job #1876655) | Cod sursa (job #2075681)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("gardieni.in");
ofstream out("gardieni.out");
struct gardieni {
long long a, b, c; }v[100000];
int main() {
long long n, t, MIN = 1000000, s = 0;
in >> n >> t;
long long a[t][n];
for (long long i = 1; i <= n; i++)
in >> v[i].a >> v[i].b >> v[i].c;
for (long long i = 1; i <= n; i++) {
for (long long j = 1; j <= t; j++) {
a[i][j] = 0;
if ((v[i].a <= j) && (j <= v[i].b))
a[i][j] = v[i].c;
}
}
for (long long i = 1; i <= t; i++) {
for (long long j = 1; j <= n; j++) {
if ((a[j][i] < MIN) && (a[j][i] != 0))
MIN = a[j][i];
if (j == n) {
s += MIN;
MIN = 50000;
}
}
}
out << s;
return 0;
}