Pagini recente » Cod sursa (job #1655407) | Cod sursa (job #2782607) | Cod sursa (job #3124796) | Cod sursa (job #2243988) | Cod sursa (job #1266421)
#include<fstream>
#include<set>
#include<algorithm>
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
struct oaie{
int sup, lan;
};
const int nmax = 100006;
int n, x, l, ce;
oaie v[nmax];
multiset <int> s;
long long rasp;
int compar(oaie a, oaie b)
{
return a.sup<b.sup;
}
int main(){
int player_unu=0;
in>>n>>x>>l;
for(int i = 1; i<=n; i++)
{
in>>v[i].sup>>v[i].lan;
if(v[i].sup>x)
{
n--;
i--;
}
else
{
v[i].sup = (x - v[i].sup) / l + 1;
}
}
sort(v + 1, v + n + 1, compar);
s.insert(-v[n].lan);
for(int i = n - 1; i>=0; i--)
{
if(v[i].sup!=v[i + 1].sup)
{
ce = v[i + 1].sup - v[i].sup;
while(s.empty()==0 && ce!=0)
{
ce--;
rasp += (long long)(-(*s.begin()));
s.erase(s.begin());
}
s.clear();
}
s.insert(-v[i].lan);
}
out<<rasp<<'\n';
return player_unu;
}