Cod sursa(job #1494564)
| Utilizator | Data | 1 octombrie 2015 13:54:40 | |
|---|---|---|---|
| Problema | Lupul Urias si Rau | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include<fstream>
#include<queue>
#include<algorithm>
using namespace std;
ifstream f("lupu.in");
ofstream g("lupu.out");
priority_queue<int> ST;
pair <int,int> a[100010];
int n,x,k,d,i;
long long sol;
int main()
{ f>>n>>x>>k;
for(i=1;i<=n;++i) f>>a[i].first>>a[i].second;
sort(a+1,a+n+1);
for(d=0,i=1;d<=x;d+=k)
{ while(i<=n && a[i].first<=d) ST.push(a[i++].second);
if(!ST.empty()) {sol+=ST.top(); ST.pop();}
}
g<<sol;
}
