Pagini recente » Cod sursa (job #2753026) | Cod sursa (job #256552) | Istoria paginii runda/simulareoji2003/clasament | Borderou de evaluare (job #1769968) | Cod sursa (job #801129)
Cod sursa(job #801129)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
#include <vector>
#define s second
using namespace std;
vector<pair<int,int> > v;
set<int> mp;
int main()
{
int n,x,l,d,lana;
ifstream f("lupu.in");
ofstream g("lupu.out");
f>>n>>x>>l;
for(int i=1;i<=n;i++)
{
mp.insert(-i);
f>>d>>lana;
v.push_back(make_pair(-lana,d));
}
sort(v.begin(),v.end());
long long rez=0,maxim=0;
for(unsigned int i=0;i<v.size();i++)
{
int tura=(x-v[i].s)/l+1;
set<int>::iterator it=mp.lower_bound(-tura);
if(it!=mp.end())
{
rez-=v[i].first;
mp.erase(it);
}
}
g<<rez;
}