QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#444001#6540. Beautiful Sequence_l_l_WA 0ms3796kbC++14450b2024-06-15 17:02:262024-06-15 17:02:27

Judging History

你现在查看的是最新测评结果

  • [2024-06-15 17:02:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-06-15 17:02:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
int main() {
	int t; scanf("%d", &t); while (t--) {
		int n; scanf("%d", &n); map<int, int> mp;
		for (int i = 1; i <= n; i++) {int a; scanf("%d", &a); mp[a]++;}
		vector<int> p; for (auto x : mp) p.push_back(x.second);
		reverse(p.begin(), p.end()); int ans = n;
		for (int x : p) {
			if (n > x) ans--, n -= x + 1;
			else n = -1;
		}
		printf("%d\n", ans);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3796kb

input:

2
6
1 1 2 3 3 4
5
1 2 2 3 3

output:

4
4

result:

ok 2 number(s): "4 4"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3768kb

input:

2
5
1 2 2 3 3
20
1 1 1 1 1 1 4 5 8 8 8 8 9 9 9 9 10 10 10 10

output:

4
15

result:

wrong answer 2nd numbers differ - expected: '17', found: '15'