Cod sursa(job #3279166)

Utilizator Roman70Maruseac Roman Roman70 Data 21 februarie 2025 23:08:18
Problema Lupul Urias si Rau Scor 8
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    freopen("lupu.in","r",stdin);
    freopen("lupu.out","w",stdout);
    int n,x,l;
    cin >> n >> x >> l;
    map<int,int>c;
    for(int i = 0;i<n;i++){
        int d;
        cin >> d;
        int v;
        cin >> v;
        if(x >= d){
            int pasi = x-d;
            int ans = pasi / l;
            if(pasi % l) ans++;
            c[ans] = max(c[ans],v);
        }
      
    }
    long long ans = 0;
    for(auto p : c){
        ans += p.second;
    }
    cout << ans;

    return 0;
}