Pagini recente » Cod sursa (job #1820735) | Cod sursa (job #1502073) | Cod sursa (job #285117) | Cod sursa (job #2466161) | Cod sursa (job #922980)
Cod sursa(job #922980)
#include<stdio.h>
#include<algorithm>
#include<vector>
#define d first
#define b second
#include<queue>
using namespace std;
pair <int , int>a[100001];
vector<int>mat[100001];
priority_queue<int>pq;
int n , x , l;
int main()
{
freopen("lupu.in" , "r" , stdin);
freopen("lupu.out" , "w" , stdout);
scanf("%d %d %d" , &n , &x , &l);
for (int i=1 ; i<=n ; ++i)
{
scanf("%d %d" , &a[i].d , &a[i].b);
if(x >= a[i].d)
mat[(x-a[i].d)/l+1].push_back(i);
}
int ans=0;
for(int t=n ; t>=1 ; --t)
{
for(int i=0 ; i<mat[t].size() ; ++i)
pq.push(a[mat[t][i]].b);
if(! pq.empty())
{
ans+=pq.top();
pq.pop();
}
}
printf("%d" , ans);
return 0;
}