Cod sursa(job #2075353)

Utilizator SburlyAndrei Florin Sburly Data 25 noiembrie 2017 12:57:09
Problema Gardieni Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>

using namespace std;

long int v[1000001], n, t;

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

    f >> n >> t;
    for(long int i = 0; i < n; i++)
    {
        long int a, b, c;
        f >> a >> b >> c;
        for(long int j = a; j <= b; j++)
            if(v[j] == 0 || v[j] > c)
                v[j] = c;
    }
    long int s = 0;
    for(long int j = 1; j <= t; j++)
        s+=v[j];
    g << s;

    return 0;
}