文章
28
粉丝
230
获赞
23
访问
244.0k
#include <iostream>
#include <algorithm>
using namespace std;
typedef struct Cai
{
int info;
int cost;
}Cai;
bool Cmpare(const Cai &a,const Cai &b){
return a.info > b.info;//升序
}
int main(int argc, char const *argv[])
{
int C,N,Info,Cost;
Cai A[100];
while(cin>>C>>N){
Info=Cost=0;
for (int i = 0; i < N; ++i)
{
cin>>A[i].cost>>A[i].info;
}
sort(A,A+N,Cmpare);
for (int i = 0; i < N; ++i)
{
if (Cost+A[i].cost<=90)
{
Info+=A[i].info;
Cost+=A[i].cost;
}else{
break;
}
}
cout<<Info<<endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发