QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578189#9313. Make MaxaikongskyWA 0ms3612kbC++14885b2024-09-20 17:14:182024-09-20 17:14:18

Judging History

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

  • [2024-09-20 17:14:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-20 17:14:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
typedef long long ll;
int a[N],cnt[N];
int n,t;
void solve()
{
//	memset(cnt,0,sizeof(cnt));
	
	ll sum = 0;
	cin>>n;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
//	cout<<endl;
//	cout<<"下面是答案:"<<endl; 
	if(n == 2) {
		if(a[1] != a[2]) cout<<"1"<<endl;
		else cout<<"0"<<endl;
	}
	else {
		int max = a[n];
		for(int i = 1;i < n;i++)
		{
			cnt[a[i]]++;
		}
		for(int i = 1;i < n - cnt[max];i++)
		{
		//	cout<<"cnt["<<a[i]<<"] = "<<cnt[a[i]]<<endl;
			if(a[i] != a[i-1])
			{
				cnt[a[i]] = cnt[a[i]] + cnt[a[i-1]];
			//	cout<<"cnt["<<a[i]<<"] = "<<cnt[a[i]]<<endl;
				sum += cnt[a[i]];
			}
			cnt[a[i]] = 0;
		}
	    cout<<sum<<endl;
	}
	
//	cout<<endl;
}
int main()
{
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
3
5

result:

wrong answer 4th numbers differ - expected: '3', found: '5'