Cod sursa(job #1768075)
| Utilizator | Data | 30 septembrie 2016 09:40:14 | |
|---|---|---|---|
| Problema | Lupul Urias si Rau | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Teme Pregatire ACM Unibuc 2014, Anul II | Marime | 0.57 kb |
#include<fstream>
#include<algorithm>
#include<queue>
using namespace std;
ifstream f("lupu.in");
ofstream g("lupu.out");
priority_queue<int>heap;
pair<int,int>v[100005];
int main()
{
int i,n,x,l,j;
long long sol=0;
f>>n>>x>>l;
for(i=1;i<=n;i++)
f>>v[i].first>>v[i].second;
sort(v+1,v+n+1);
for(j=0,i=1;j<=x;j=j+l)
{
while(i<=n&&v[i].first<=j)
heap.push(v[i++].second);
if(!heap.empty())
{
sol=sol+heap.top();
heap.pop();
}
}
g<<sol;
return 0;
}
