QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#423299 | #6540. Beautiful Sequence | wdnmdwrnmmp | WA | 0ms | 3728kb | C++14 | 1.1kb | 2024-05-27 22:08:22 | 2024-05-27 22:08:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef vector<int> vi;
typedef pair<int,int> pi;
void solve(){
int n; cin>>n;
vi a(n+1);
rep(i,0,n-1){
cin>>a[i];
}
sort(a.begin(), a.begin()+n);
a[n]=-1;
int cnt=1;
priority_queue<int, vi, greater<int>> Q;
rep(i,1,n){
if(a[i]!=a[i-1]){
Q.push(cnt);
int x=Q.top();
Q.pop();
if(x>=0){
Q.push(x-1);
}
cnt=0;
}
cnt++;
}
int ans=0;
while(!Q.empty()){
ans+=max(0, Q.top());
Q.pop();
}
cout<<ans<<'\n';
}
signed main(){
#ifndef ONLINE_JUDGE
assert(freopen(".in","r",stdin));
// assert(freopen(".out","w",stdout));
#endif
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t; cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
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: 0
Accepted
time: 0ms
memory: 3728kb
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 17
result:
ok 2 number(s): "4 17"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
300 14 1 1 1 2 2 2 3 3 3 4 5 5 6 6 14 1 1 1 2 2 3 3 4 4 5 5 6 7 7 14 1 1 2 2 3 4 4 4 5 5 5 6 6 6 14 1 1 2 2 3 3 3 4 5 5 5 6 6 6 14 1 1 1 1 1 1 2 2 2 2 2 3 3 3 14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 1 2 2 3 4 5 5 6 6 6 7 8 8 8 14 1 2 2 2 2 2 3 4 5 6 7 8 9 10 14 1 2 2 3 4 4 4 5 6 6 6 6 6 7 14 1 1 2 2 2 3 3...
output:
10 10 11 11 11 13 11 10 11 11 10 11 10 10 11 11 11 10 10 12 11 10 11 11 12 11 11 11 11 11 11 9 11 11 11 11 12 13 10 12 11 12 10 11 11 11 11 10 11 9 11 10 11 10 11 10 11 11 12 11 12 10 11 11 11 11 10 11 12 11 10 10 10 11 11 10 11 11 11 10 10 11 9 11 10 12 11 12 11 12 10 10 11 10 12 11 10 11 11 11 11 ...
result:
wrong answer 2nd numbers differ - expected: '9', found: '10'