Pagini recente » Cod sursa (job #1137069) | Cod sursa (job #3191143) | Cod sursa (job #2903946) | Cod sursa (job #2017663) | Cod sursa (job #1107746)
#include<fstream>
using namespace std;
#include<algorithm>
#include<set>
ifstream f("lupu.in");
ofstream g("lupu.out");
#define nmax 100010
long long sol;
int n,x,d;
struct elem
{
int ln;
int x;
} oi[nmax];
struct cmp
{
bool operator()(const int &a,const int &b)
{
return a>b;
}
};
bool comp (elem a,elem b)
{
return a.x<=b.x;
};
multiset <int,cmp> h;
int main()
{
f>>n>>x>>d;
for(int i=1;i<=n;i++)
f>>oi[i].x>>oi[i].ln;
sort(oi+1,oi+1+n,comp);
int k=0;
for(int i=1;oi[i].x<=x;i++)
{
if((float)oi[i].x/d<=(float)k)
h.insert(oi[i].ln);
else
{
sol+=*h.begin();
h.erase(*h.begin());
k++;
}
}
g<<sol<<'\n';
return 0;
}