Pagini recente » Cod sursa (job #388647) | Cod sursa (job #1011420) | Cod sursa (job #1265317) | Cod sursa (job #1000558) | Cod sursa (job #3267282)
#include <bits/stdc++.h>
using namespace std;
#define TITLE "lupu"
ifstream f (TITLE".in");
ofstream g (TITLE".out");
int main()
{
long long int n,x,l;
f>>n>>x>>l;
priority_queue<pair<long long int,long long int>> PQ;
for(int i=1;i<=n; i++)
{
int a,b;
f>>a>>b;
PQ.push({b,-1*((x-a)/l+1)});
}
long long int Ans=0;
for(int i=1; !PQ.empty(); PQ.pop())
{
if(-PQ.top().second>=i)
{
i++;
Ans+=PQ.top().first;
}
}
g<<Ans;
return 0;
}