QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#443277#6540. Beautiful SequenceFirminoWA 0ms3636kbC++14563b2024-06-15 15:00:032024-06-15 15:00:04

Judging History

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

  • [2024-06-15 15:00:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-06-15 15:00:03]
  • 提交

answer

#include <iostream>
#include <algorithm>
using namespace std;
int read(){
	int re=0,c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') re=(re<<3)+(re<<1)+(c^48),c=getchar();
	return re;
}
const int maxn=3e5+5;
int n,a[maxn];
void init(){
	
}
void solve(){
	n=read();
	init();
	for (int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1);
	int cs=0,ans=0;
	for (int i=n;i;i--){
		if(a[i]!=a[i+1]) cs++;
		if(i-1>=cs-1) ans=max(ans,n-i+1);
	}
	cout<<ans<<endl;
}
int main(){
	int t=read();
	while(t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3560kb

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'