Pagini recente » Cod sursa (job #992865) | Cod sursa (job #1955915) | Cod sursa (job #2156730) | Cod sursa (job #858967) | Cod sursa (job #2876927)
#include <bits/stdc++.h>
#define nmax 100005
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
struct oaie
{
int t,lana;
oaie(int t=-1,int lana=0)
{
this->t=t;
this->lana=lana;
}
bool operator <(const oaie other)
{
return t>other.t;
}
} oi[nmax];
int main()
{
int n,x,l;
in>>n>>x>>l;
for(int i=0;i<n;i++)
{
int d,lana;
in>>d>>lana;
oi[i]=oaie((x-d)/l,lana);
}
sort(oi,oi+n);
int64_t res=0;
priority_queue<int> q;
int ind=0;
for(int i=x/l;i>=0;i--)
{
while (oi[ind].t==i)
{
q.push(oi[ind].lana);
ind++;
}
if(!q.empty())
{
res+=q.top();
q.pop();
}
}
out<<res;
}