結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | ciel |
提出日時 | 2015-01-12 02:34:01 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 583 ms |
コンパイル使用メモリ | 69,772 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-04 05:00:29 |
合計ジャッジ時間 | 1,352 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
4,376 KB |
testcase_01 | AC | 30 ms
4,376 KB |
testcase_02 | AC | 16 ms
4,376 KB |
testcase_03 | AC | 31 ms
4,380 KB |
ソースコード
#include <queue> #include <map> #include <cstdio> using namespace std; int main(){ int T,N,L; for(scanf("%d",&T);T--;){ map<int,int>m; for(scanf("%d",&N);N--;m[L]++)scanf("%d",&L); priority_queue<pair<int,int> >q; for(map<int,int>::iterator it=m.begin();it!=m.end();++it)q.push(make_pair(it->second,it->first)); int r=0; for(;q.size()>2;r++){ vector<pair<int,int> >v(3); for(int i=0;i<3;i++)v[i]=q.top(),q.pop(); for(int i=0;i<3;i++)if(v[i].first>1)q.push(make_pair(v[i].first-1,v[i].second)); } printf("%d\n",r); } }