Pagini recente » Cod sursa (job #3130743) | Cod sursa (job #508056) | Cod sursa (job #172606) | Arhiva de probleme | Cod sursa (job #1293530)
#include <fstream>
#include <algorithm>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
ifstream is("lupu.in");
ofstream os("lupu.out");
int N, X, L;
pair <int, int> x;
vector <pair<int,int> > V;
int maximr(-999999999);
priority_queue <int> Q;
int main()
{
is >> N >> X >> L;
for ( int i = 1; i <= N; ++i )
{
is >> x.first >> x.second;
x.first = (X-x.first)/L;
V.push_back(x);
}
sort(V.begin(),V.end());
int it = N-1, Sol = 0;
for ( int i = 3; i >= 0; --i )
{
for ( ; V[it].first == i; --it )
Q.push(V[it].second);
if ( !Q.empty() )
Sol += Q.top(), Q.pop();
}
os << Sol;
}