QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168830 | #6540. Beautiful Sequence | PhantomThreshold | WA | 2ms | 3628kb | C++20 | 629b | 2023-09-08 23:23:33 | 2023-09-08 23:23:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxn=300000;
int T;
int n;
int a[maxn+50];
int main(){
ios_base::sync_with_stdio(false);
cin >> T;
for (;T--;){
cin >> n;
for (int i=1;i<=n;i++) cin >> a[i];
map<int,int> dict;
for (int i=1;i<=n;i++) dict[a[i]]++;
priority_queue<pii,vector<pii>,greater<pii>> q;
int v=0;
for (auto [x,cnt]:dict){
q.emplace(cnt,x);
while (q.size()>v+1){
auto qf=q.top();
q.pop();
if (qf.first!=1) q.emplace(qf.first-1,qf.second);
v++;
}
}
cout << n-q.size()+1 << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3628kb
input:
2 6 1 1 2 3 3 4 5 1 2 2 3 3
output:
5 4
result:
wrong answer 1st numbers differ - expected: '4', found: '5'