Pagini recente » Istoria paginii runda/testulet | Cod sursa (job #1781458) | Cod sursa (job #2960646) | Cod sursa (job #2020256) | 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;
}