結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-09-21 07:17:28 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 608 bytes | 
| コンパイル時間 | 606 ms | 
| コンパイル使用メモリ | 69,032 KB | 
| 実行使用メモリ | 11,044 KB | 
| 最終ジャッジ日時 | 2024-11-17 10:18:35 | 
| 合計ジャッジ時間 | 7,403 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 3 TLE * 1 | 
ソースコード
#include <iostream>
#include <map>
using namespace std;
int main(){
  int T,N,L;
  cin>>T;
  for(int i=0; i<T; ++i){
    cin>>N;
    if(N<3){
      cout<<0<<endl;
    } else {
    map<int,int> m;
    int a=N/3;
    int b=N%3;
    for(int j=0; j<N; ++j){
      cin>>L;
      size_t n=m.count(L);
      if(n>0){
        m[L]+=1;
      } else {
        m.insert(make_pair(L,1));
      }
    }
    for(auto it=m.begin(); it!=m.end(); ++it){
      int c=it->second;
      if(c>a){
        if(b>0){
          b-=1;
        } else{
          a-=1;
        }
      }
    }
    cout<<a<<endl;
    }
  }
  return 0;
}
            
            
            
        