Pagini recente » Unirea 2007, Clasament pentru clasele XI-XII | Cod sursa (job #2636079) | Cod sursa (job #953047) | Cod sursa (job #1797784) | Cod sursa (job #1794562)
#include<fstream>
#include<string.h>
#include<ctype.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<array>
#include<deque>
#include<math.h>
#include<functional>
#include<unordered_set>
#include<set>
#include<iomanip>
#include<bitset>
using namespace std;
int n,i,j,k,el,nr,ok,x,l,lana,dist,max1;
long long rez;
multimap<int, int,greater<int>>oi;
multimap<int, int, greater<int>>::iterator it;
int main()
{
//ifstream f("file.in");
//ofstream g("file.out");
ifstream f("lupu.in");
ofstream g("lupu.out");
f >> n >> x >> l;
for (i = 1; i <= n; i++)
{
f >> dist >> lana;
if (dist <= x)
{
dist = (x - dist) / l + 1;
oi.insert(make_pair(dist, lana));
}
}
it = oi.begin();
while (it != oi.end())
{
max1 = -1 * 1 << 30;
dist = it->first;
max1 = max(it->second, max1);
it++;
while (it != oi.end() && dist == it->first)
{
max1 = max(max1, it->second);
it++;
}
rez += max1;
}
g << rez;
return 0;
}