Pagini recente » Cod sursa (job #2899432) | Cod sursa (job #720293) | Cod sursa (job #1114301) | Cod sursa (job #3243570) | Cod sursa (job #2967431)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
const int NMAX = 1e5 + 5;
int n,x,dx,rasp;
struct oaieStr
{
int d,l;
bool operator < (const oaieStr &a) const
{
return l<a.l;
}
} v[NMAX];
bool sortare (const oaieStr &a, const oaieStr &b)
{
return a.d<b.d;
}
priority_queue<oaieStr> pq;
int main()
{
fin>>n>>x>>dx;
for(int i=0; i<n; i++)
{
fin>>v[i].d>>v[i].l;
}
sort(v,v+n,sortare);
int lim = x%dx,i = 0;
while(lim<=x)
{
for(; i<n && v[i].d <=lim; i++)
{
pq.push(v[i]);
}
cout<<pq.top().l<<" "<<pq.top().d<<"\n";
if(!pq.empty())
{
rasp+=pq.top().l;
pq.pop();
}
lim+=dx;
}
fout<<rasp;
return 0;
}