#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
struct mst{
int a;
int b;
double c;
}mo[105];
bool cmp(mst x,mst y){
return x.c>y.c;
}
bool niao[105];
int main(){
srand(time(0));
ofstream fout("C:/Users/fangzhixiang/Desktop/2.in");
int n,m;
while(1>n||n>100){
n=rand();
}
while(10>m||m>200){
m=rand();
}
cout<<n<<' '<<m<<endl;
fout<<n<<' '<<m<<endl;
for(int i=1;i<=n;i++){
while(500<mo[i].a||mo[i].a<1){
mo[i].a=rand();
}
while(100<mo[i].b||mo[i].b<1){
mo[i].b=rand();
}
cout<<mo[i].a<<' '<<mo[i].b<<endl;
fout<<mo[i].a<<' '<<mo[i].b<<endl;
mo[i].c=mo[i].a/mo[i].b;
}
int x,y;
if(m<=25)
while(x<10||x>100){
x=rand();
}
else
while(x<100||x>1000){
x=rand();
}
while(y<10||y>1000){
y=rand();
}
cout<<x<<' '<<y;
fout<<x<<' '<<y;
fout.close();
sqrt(mo,mo+n,cmp);
int ans=0;
ofstream nout("C:/Users/fangzhixiang/Desktop/2.out");
for(int j=1;j<=n;j++){
for(int i=0;i<n;i++){
if(niao[i]==false&&mo[i].a<m){
m+=mo[i].a;
ans+=mo[i].b;
niao[i]=true;
break;
}else
if(n==i){
nout<<-1;
cout<<-1;
return 0;
}
}
}
if(m>=x){
ans+=n;
nout<<ans;
}else{
nout<<-1;
}
nout.close();
return 0;
}
51 21
[Error] no matching function for call to 'sqrt(mst [105], mst*, bool (&)(mst, mst))'