Cod sursa(job #2231125)

Utilizator DenisacheDenis Ehorovici Denisache Data 13 august 2018 02:23:09
Problema Lupul Urias si Rau Scor 16
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <set>
#include <unordered_map>

using namespace std;



int main() {
	ios::sync_with_stdio(false);

	ifstream cin("lupu.in");
	ofstream cout("lupu.out");

	int n, x, l;
	cin >> n >> x >> l;

	unordered_map<int, int> ump;

	for (int i = 0; i < n; ++i) {
		int d, a;
		cin >> d >> a;

		if (d > x) continue;
		ump[(x - d + l) / l] = max(ump[(x - d + l) / l], a);
	}

	long long ans = 0LL;
	for (auto& pr : ump)
		ans += pr.second;

	cout << ans;

	//system("pause");
	return 0;
}