結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
![]() |
提出日時 | 2015-01-29 17:46:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 593 ms |
コンパイル使用メモリ | 66,684 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 03:48:45 |
合計ジャッジ時間 | 1,266 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 4 |
ソースコード
#include <iostream> #include <map> using namespace std; int main() { int T; cin>>T; while (T--) { int n; cin>>n; map<int, int> a; while (n--) { int l; cin>>l; a[l]++; } int res=0; while (a.size()>2) { map<int,int>::iterator i=a.begin(); decltype(i) j=i; ++j; decltype(i) k=j; ++k; i->second--; if (i->second==0) a.erase(i); j->second--; if (j->second==0) a.erase(j); k->second--; if (k->second==0) a.erase(k); ++res; } cout<<res<<endl; } }