結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー itezpaceitezpace
提出日時 2016-09-21 07:17:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 69,084 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-28 16:41:35
合計ジャッジ時間 7,256 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0