結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-15 11:38:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 5,000 ms |
| コード長 | 1,067 bytes |
| コンパイル時間 | 1,686 ms |
| コンパイル使用メモリ | 177,556 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 14:44:34 |
| 合計ジャッジ時間 | 2,360 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) (a)<=(n)&&(n)<(b)
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
const ll inf =1e18;
int T;
int main(){
while(cin>>T){
REP(t,0,T){
int N;
cin>>N;
int ans=0;
map<int,int> m;
REP(i,0,N){
int l;
cin>>l;
m[l]++;
}
priority_queue<int> pq;
for(auto mm:m){
pq.push(mm.second);
}
while(pq.size()>2){
int a=pq.top(); pq.pop();
int b=pq.top(); pq.pop();
int c=pq.top(); pq.pop();
if(c==0) break;
ans++;
a--;
b--;
c--;
pq.push(a);
pq.push(b);
pq.push(c);
}
p(ans);
}
}
}
dnish