Pagini recente » Cod sursa (job #1096791) | Cod sursa (job #2683124) | Cod sursa (job #1346826) | Cod sursa (job #1850963) | Cod sursa (job #2708445)
#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;
}