Pagini recente » Cod sursa (job #639744) | Cod sursa (job #1432389) | Cod sursa (job #834740) | Cod sursa (job #1799006) | Cod sursa (job #442953)
Cod sursa(job #442953)
#include<fstream>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
struct Gutui{
unsigned long h;
unsigned long w;
bool operator() (Gutui a, Gutui b) { if (a.h == b.h) return (a.w<b.w);return (a.h<b.h); }
}gutui;
int main(){
unsigned long n,h,u,u1=0,hmax=0,umax=0;
ifstream fin ("gutui.in");
ofstream fout ("gutui.out");
fin>>n>>h>>u;
vector<Gutui> g(n);
for (int i=0; i<n; i++)
fin>>g[i].h>>g[i].w;
sort(g.begin(),g.end(),gutui);
for (int i=n-1; i>=0; i--)
{
while (g[i].h+u1 < h)
{
hmax=g[i].h;
u1+=10;
umax+=g[i].w;
}
}
fout<<umax<<endl;
for (int i=0; i<n; i++)
fout<<g[i].h<<" "<<g[i].w<<endl;
fin.close();
fout.close();
return 0;
}