#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,m;
cin>>t>>m;
int tf[m],moneyf[m],ts[m],moneys[m];
double xjbf[m],xjbs[m] = {0};
for(int i = 0;i<m;i++)
{
cin>>tf[i]>>moneyf[i];
}
for(int i = 0;i<m;i++)
{
xjbf[i] = moneyf[i]/tf[i];
}
for(int i = m;i>0;i--)
{
for(int j = 0;j<m;j++)
{
if(xjbf[j]>xjbs[i])
{
xjbs[i] = xjbf[j];
ts[i] = tf[j];
moneys[i] = moneyf[j];
xjbf[j] = 0;
}
}
}
int allt = 0,allm = 0,i = 0;
do
{
if(ts[0]>allt)
{
break;
}
allt+=ts[i];
allm+=moneys[i];
i++;
}
while(allt+ts[i]<=t);
cout<<allm<<endl;
return 0;
}
全部报WA,求帮助,thanks