Cod sursa(job #2907679)

Utilizator amcbnCiobanu Andrei Mihai amcbn Data 31 mai 2022 08:58:44
Problema Lupul Urias si Rau Scor 8
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
/// [A][M][C][B][N] ///
#include <bits/stdc++.h>
using namespace std;
const int mod = 9901, inf = 0x3f3f3f3f;
const char sp = ' ', nl = '\n';
ifstream fin("lupu.in");
ofstream fout("lupu.out");

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, x, l;
    fin >> n >> x >> l;
    priority_queue<pair<int, int> > pq;
    for (int i = 0; i < n; ++i) {
        pair<int, int> foo;
        fin >> foo.second >> foo.first;
        pq.push(foo);
    }
    long long cost = 0;
    while (pq.size()) {
        pair<int, int> t = pq.top();
        pq.pop();
        if (t.second > x) {
            continue;
        }
        cost += t.first;
        x -= l;
    }
    fout << cost;
 }