Pagini recente » Cod sursa (job #1996919) | Cod sursa (job #3278891) | Cod sursa (job #472591) | Cod sursa (job #3252068) | Cod sursa (job #2440262)
#include <bits/stdc++.h>
using namespace std;ifstream in("lupu.in");ofstream out("lupu.out");const int N = 1e5+5;pair<int,int> v[N];priority_queue<int> q;int k;int main(){int n,x,l;long long s = 0;in >> n >> x >> l;for (int i = 1; i<=n; i++){int a,d;in >> d >> a;if (d<=x)v[++k] = {(x-d)/l+1,a};}sort(v+1,v+k+1);int t = v[k].first;for (int pas = t; pas>=1; pas--){while (k>=1 && v[k].first == pas){q.push(v[k].second);k--;}if (!q.empty()){s+=q.top();q.pop();}}out << s;}