結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  hogeover30 | 
| 提出日時 | 2015-01-29 17:58:11 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 557 bytes | 
| コンパイル時間 | 535 ms | 
| コンパイル使用メモリ | 61,940 KB | 
| 最終ジャッジ日時 | 2024-11-14 18:58:57 | 
| 合計ジャッジ時間 | 1,510 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:9: error: ‘vector’ was not declared in this scope
   14 |         vector<int> v;
      |         ^~~~~~
main.cpp:4:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | using namespace std;
main.cpp:14:16: error: expected primary-expression before ‘int’
   14 |         vector<int> v;
      |                ^~~
main.cpp:15:25: error: ‘v’ was not declared in this scope
   15 |         for(auto& x: a) v.push_back(x.second);
      |                         ^
main.cpp:16:14: error: ‘v’ was not declared in this scope
   16 |         sort(v.rbegin(), v.rend());
      |              ^
            
            ソースコード
#include <iostream>
#include <map>
#include <algorithm>
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]++;
        }
        vector<int> v;
        for(auto& x: a) v.push_back(x.second);
        sort(v.rbegin(), v.rend());
        int res=0, m=v.size();
        while (m>2) {
            ++res;
            for(int i=0;i<3;++i) if (--v[i]==0) --m;
            sort(v.rbegin(), v.rend());
        }
        cout<<res<<endl;
    }
}
            
            
            
        