problem-A. Organizing SWERC-codeforces

题目:

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;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

'<王半仙>'

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值