Cod sursa(job #3347156)

Utilizator BuzdiBuzdugan Rares Andrei Buzdi Data 15 martie 2026 18:46:31
Problema Lupul Urias si Rau Scor 16
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ifstream fin("lupu.in");
ofstream fout("lupu.out");

const int MMAX = 1e5;

int n, x, l;
ll answer;
map<int, int> mp;

int main() {
    fin >> n >> x >> l;
    for(int i = 1; i <= n; i++) {
        int d, c;
        fin >> d >> c;
        if(x - d >= 0) {
            int k = (x - d) / l;
            if(!mp.count(k)) {
                mp[k] = c;
            }
            else {
                mp[k] = max(mp[k], c);
            }
        }
    }

    for(auto x : mp) {
        answer += x.second;
    }
    fout << answer << '\n';
    return 0;
}