QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168830#6540. Beautiful SequencePhantomThresholdWA 2ms3628kbC++20629b2023-09-08 23:23:332023-09-08 23:23:34

Judging History

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

  • [2023-09-08 23:23:34]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3628kb
  • [2023-09-08 23:23:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> pii;
const int maxn=300000;
int T;
int n;
int a[maxn+50];

int main(){
	ios_base::sync_with_stdio(false);
	cin >> T;
	for (;T--;){
		cin >> n;
		for (int i=1;i<=n;i++) cin >> a[i];
		map<int,int> dict;
		for (int i=1;i<=n;i++) dict[a[i]]++;
		priority_queue<pii,vector<pii>,greater<pii>> q;
		int v=0;
		for (auto [x,cnt]:dict){
			q.emplace(cnt,x);
			while (q.size()>v+1){
				auto qf=q.top();
				q.pop();
				if (qf.first!=1) q.emplace(qf.first-1,qf.second);
				v++;
			}
		}
		cout << n-q.size()+1 << "\n";
	}
	return 0;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3628kb

input:

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

output:

5
4

result:

wrong answer 1st numbers differ - expected: '4', found: '5'