QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#443391#6540. Beautiful Sequencezwh2008WA 1ms5756kbC++14554b2024-06-15 15:25:242024-06-15 15:25:34

Judging History

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

  • [2024-06-15 15:25:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5756kb
  • [2024-06-15 15:25:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pi=pair<int,int>;
#define fi first
#define se second
const int N=3e5+5;
int n,m,a[N],b[N];
void solve() {
	cin>>n,m=0;
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=0;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)m+=a[i]!=a[i-1],b[m]++;
	int s=0,ans=0;
	for(int i=0;i<m;i++) {
		s+=b[i];int t=m-i-1;
		if(s>=t){ans=n-s+max(s-t-1,0);break;}
	}cout<<ans<<'\n';
}
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int tt;cin>>tt;
	while(tt--)solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5756kb

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

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'