QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578233#9313. Make MaxaikongskyWA 1ms4588kbC++14645b2024-09-20 17:33:482024-09-20 17:33:49

Judging History

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

  • [2024-09-20 17:33:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4588kb
  • [2024-09-20 17:33:48]
  • 提交

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]);
		cnt[a[i]]++;
	}
	sort(a+1,a+1+n);
	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 - cnt[max];i++)
		{
			if(a[i] != a[i-1])
			{
				cnt[a[i]] = cnt[a[i]] + cnt[a[i-1]];
				sum += cnt[a[i]];
			}
		}
	    cout<<sum<<endl;
	}
}
int main()
{
	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4588kb

input:

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

output:

1
0
3
1

result:

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