Cod sursa(job #2708445)

Utilizator DordeDorde Matei Dorde Data 18 februarie 2021 18:52:48
Problema Lupul Urias si Rau Scor 8
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <map>
using namespace std;
int const N  = 1e5 + 3;
typedef long long ll;
ifstream f ("lupu.in");
ofstream g ("lupu.out");
map <int , int> v;
int main()
{
    int n , x , D;
    ll r = 0;
    f >> n >> x >> D;
    for(int i = 1 ; i <= n ; ++ i){
        int a , b;
        f >> a >> b;
        if (a > x)
            continue;
        v [(x - a) / D + (bool)((x - a) % D)] = max (b , v [(x - a) / D + (bool)((x - a) % D)] );
    }
    for(auto it : v)
        r += 1LL * it . second;
    g << r;
    return 0;
}