Pagini recente » Cod sursa (job #1663221) | Cod sursa (job #516520) | Cod sursa (job #1782373) | Cod sursa (job #289818) | Cod sursa (job #1464983)
#include <fstream>
#include <limits>
#include <queue>
#include <vector>
#include <algorithm>
#define INF numeric_limits<int>::max()
#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(a,b));
}
int d=0,sol=0;
while(!h.empty())
{
int mx=-INF;
while(h.top().first+d > x)h.pop();
while(h.top().first+d+l > x && !h.empty())
{
mx=max(mx,h.top().second);
h.pop();
}
if(mx!=-INF)sol+=mx;
d+=l;
}
out<<sol<<'\n';
return 0;
}