Pagini recente » Cod sursa (job #147403) | Cod sursa (job #1917386) | Cod sursa (job #1522555) | Cod sursa (job #158796) | Cod sursa (job #1464882)
#include <fstream>
#include <limits>
#include <queue>
#include <vector>
#include <algorithm>
#define int64 long long
#define pb push_back
#define mp make_pair
#define mod(x) ( (x) > 0 ? (x) : (-x) )
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
priority_queue< pair<int,int> > h;
int n,x,l;
int main()
{
in>>n>>x>>l;
for(int i=1;i<=n;i++)
{
int a,b;
in>>a>>b;
h.push(mp(b,a));
}
int d=0,sol=0;
while(!h.empty())
{
while(h.top().second+d > x && !h.empty())h.pop();
if(!h.empty())
{
sol+=h.top().first;
h.pop();
}
d+=l;
}
out<<sol<<'\n';
return 0;
}