将统计最大美观度的变量初始化为 ,然后求出每个难度题目的美观度的最大值,若某个难度的美观度最大值为 ,说明没有这个难度的题目,输出 MOREPROBLEMS。否则输出所有难度题目的美观度最大值之和即可。
代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ft first
#define sd second
#define fs(i,x,y) for(int i=(x);i<=(y);i++)
#define fj(i,x,y) for(int i=(x);i>=(y);i--)
signed main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
int n,maxx[15]={0},b,d;
cin>>n;
fs(i,1,n){
cin>>b>>d;
maxx[d]=max(maxx[d],b);
}
int sum=0;
bool flag=1;
fs(i,1,10){
sum+=maxx[i];
if(maxx[i]==0){
cout<<"MOREPROBLEMS\n";
flag=0;
break;
}
}
if(flag)cout<<sum<<'\n';
}
return 0;
}