Cod sursa(job #1404246)

Utilizator iordache.bogdanIordache Ioan-Bogdan iordache.bogdan Data 27 martie 2015 22:36:26
Problema Gardieni Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
#include <algorithm>

#define DIM 1000010
#define INF (1 << 21)
#define infile "gardieni.in"
#define outfile "gardieni.out"

using namespace std;

ifstream fin(infile);
ofstream fout(outfile);

int minCost[DIM];

int main() {

	int n, t;

	fin >> n >> t;

	for (int i = 1; i <= t; ++i)
		minCost[i] = INF;

	for (int i = 1; i <= n; ++i) {

		int a, b, c;

		fin >> a >> b >> c;

		for (int j = a; j <= b; ++j)
			minCost[j] = min(minCost[j], c);

	}

	long long totalCost = 0;

	for (int i = 1; i <= t; ++i)
		totalCost += minCost[i];

	fout << totalCost;

	return 0;
}

//Trust me, I'm the Doctor!
//Miriam e tare!