Cod sursa(job #2708443)

Utilizator DordeDorde Matei Dorde Data 18 februarie 2021 18:51:49
Problema Lupul Urias si Rau Scor 8
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
#include <map>
using namespace std;
int const N  = 1e5 + 3;
ifstream f ("lupu.in");
ofstream g ("lupu.out");
map <int , int> v;
int main()
{
    int n , x , D , 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 += it . second;
    g << r;
    return 0;
}