Cod sursa(job #1862728)

Utilizator valentinoMoldovan Rares valentino Data 30 ianuarie 2017 10:54:31
Problema Lupul Urias si Rau Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include <fstream>

#include <vector>

#include <queue>

using namespace std;

 

ifstream f("lupu.in");

ofstream g("lupu.out");

 

priority_queue < int > heap;

vector < int > v[100005];

int n, a, t ,d, l, tmax;

 

int main()

{

    long long int sol = 0;

    f >> n >> d >> l;

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

    {

        f >> t >> a;
if(d>=t)

       {
	
t = (d - t) / l;

        v[t].push_back(a);

        tmax = max(tmax, t);
}

    }

    for(int i = tmax; i >= 0; --i)

    {

        for(int j = 0; j < v[i].size(); ++j)

        {

           heap.push(v[i][j]);

        }

        sol += heap.top();

        heap.pop();

    }

    g << sol << '\n';

}