Pagini recente » Cod sursa (job #1549954) | Cod sursa (job #2505267) | Cod sursa (job #2633276) | Cod sursa (job #428162) | Cod sursa (job #2519000)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lupu.in");
ofstream fout("lupu.out");
struct credite
{
long long nrC, timp;
bool operator<(const credite & rhs) const
{
return nrC < rhs.nrC;
}
} c[10002];
priority_queue<long long> q;
/*bool compara(credite vs, credite vd)
{
return vs.timp<vd.timp;
}*/
int main()
{
int n,X,L;
credite v[10001]= {0};
fin>>n>>X>>L;
int p=0;
for(int i=1; i<=n; i++)
{
int x,y;
fin>>x>>y;
v[++p].nrC=y;
v[p].timp=x;
}
for(int i=1;i<=n;i++)
{
cout<<v[i].nrC<<' '<<v[i].timp<<endl;
}
int mx=v[1].timp;
int cnt=n%L;
long long s=0;
for(int i=0; i<=X; i=i+1)
{
for(int j=1;j<=n;j++)
{
if(v[j].timp==i)
{
q.push(v[j].nrC);
}
}
if(i%L==cnt)
{
s=s+q.top();
q.pop();
}
}
fout<<s;
return 0;
}