Pagini recente » Profil YorKnEz | Rating Nechita Radu (radu202) | Cod sursa (job #1749499) | Cod sursa (job #2695945) | Cod sursa (job #2418085)
#include <bits/stdc++.h>
using namespace std;
ifstream in("lupu.in");
ofstream out("lupu.out");
const int N = 1e5+5;
typedef long long ll;
priority_queue< pair<ll,ll> > q;
int main()
{
int n,x;
ll l,c = 0;
in >> n >> x >> l;
for (int i = 1; i<=n; i++)
{
pair<ll,ll> t;
in >> t.second >> t.first;
q.push(t);
}
ll 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;
}