Cod sursa(job #477169)

Utilizator dacyanMujdar Dacian dacyan Data 13 august 2010 17:54:54
Problema Gardieni Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

ifstream fin("gardieni.in");
ofstream fout("gardieni.out");

vector<long>  t;
long a, b, n, T, j, c;

int main()
{
    fin >> n >> T;
    t.resize(T+1);
    for ( long i = 0; i < n; ++i)
    {
        fin >> a >> b >> c;
        for ( j = a; j <= b; ++j)
                if ( t[j] == 0 || c < t[j])
                                t[j] = c;
    }
    fin.close();
    
    unsigned long long sol(0);
    for (long i = 1; i <= T; ++i)
        sol += t[i];
    fout << sol << '\n';
    fout.close();
    return 0;
}