题目:
Gianni, SWERC's chief judge, received a huge amount of high quality problems from the judges and now he has to choose a problem set for SWERC.
He received nn problems and he assigned a beauty score and a difficulty to each of them. The ii-th problem has beauty score equal to bibi and difficulty equal to didi. The beauty and the difficulty are integers between 11 and 1010.
If there are no problems with a certain difficulty (the possible difficulties are 1,2,…,101,2,…,10) then Gianni will ask for more problems to the judges.
Otherwise, for each difficulty between 11 and 1010, he will put in the problem set one of the most beautiful problems with such difficulty (so the problem set will contain exactly 1010 problems with distinct difficulties). You shall compute the total beauty of the problem set, that is the sum of the beauty scores of the problems chosen by Gianni.
输入:
Each test contains multiple test cases. The first line contains an integer tt (1≤t≤1001≤t≤100) — the number of test cases. The descriptions of the tt test cases follow.
The first line of each test case contains the integer nn (1≤n≤1001≤n≤100) — how many problems Gianni received from the judges.
The next nn lines contain two integers each. The ii-th of such lines contains bibi and didi (1≤bi,di≤101≤bi,di≤10) — the beauty score and the difficulty of the ii-th problem.
输出:
For each test case, print the total beauty of the problem set chosen by Gianni. If Gianni cannot create a problem set (because there are no problems with a certain difficulty) print the string MOREPROBLEMS (all letters are uppercase, there are no spaces).
Examples
input
2
3
8 4
9 3
6 7
12
3 10
10 1
10 2
10 3
10 4
3 10
10 5
10 6
10 7
10 8
10 9
1 10
output
MOREPROBLEMS
93
代码:
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
const int N = 2e5 + 10, M = 110;
const long long mod = 998244353 ;
typedef long long ll;
typedef pair<int, int> PII;
#define forn(i,a,b) for(int i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define srt(c) sort(all(c))
#define pb push_back
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
int t, n;
int b[M], d[M];
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
while (t--) {
map<int, int> m;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> b[i] >> d[i];
}
for (int i = 0; i < n; i++) {
if (!m.count(d[i]))
m.insert({d[i], b[i]});
else {
if (m[d[i]] < b[i])
m[d[i]] = b[i];
}
}
if (m.size() != 10)
cout << "MOREPROBLEMS" << endl;
else {
int ans = 0;
for (auto &k : m) {
ans += k.second;
}
cout << ans << endl;
}
}
return 0;
}