Pagini recente » Cod sursa (job #1075564) | Cod sursa (job #1290547) | Cod sursa (job #585071) | Cod sursa (job #1536914) | Cod sursa (job #2418084)
#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
const int N = 1e5+5;
priority_queue<pii> q;
int main()
{
int n,x,l,c = 0;
in >> n >> x >> l;
for (int i = 1; i<=n; i++)
{
pii t;
in >> t.second >> t.first;
q.push(t);
}
long long s = 0;
while (!q.empty())
{
while (!q.empty() && q.top().second+c*l>x)
q.pop();
if (!q.empty())
{
c++;
s+=q.top().first;
q.pop();
}
}
out << s;
}