QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#578189 | #9313. Make Max | aikongsky | WA | 0ms | 3612kb | C++14 | 885b | 2024-09-20 17:14:18 | 2024-09-20 17:14:18 |
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]);
}
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'