Cod sursa(job #1350746)

Utilizator costty94Duica Costinel costty94 Data 20 februarie 2015 22:19:34
Problema Gardieni Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
#include <fstream>

using namespace std;

int n, t, s, timp[1000100], a, b, c, i, j;

int main()
{
	ifstream f("gardieni.in");
	ofstream g("gardieni.out");

	
	f >> n >> t;
	for (i = 1; i <= t; i++)
		timp[i] = 1 << 30;
	for (i = 1; i <= n; i++)
	{
		f >> a >> b >> c;
		for (j = a; j <= b; j++)
		{
			if (timp[j] > c)
				timp[j] = c;
		}
	}
	for (i = 1; i <= t; i++)
		s += timp[i];
	g << s;
}