QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#578233 | #9313. Make Max | aikongsky | WA | 1ms | 4588kb | C++14 | 645b | 2024-09-20 17:33:48 | 2024-09-20 17:33:49 |
Judging History
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'