結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー not_522not_522
提出日時 2015-07-23 04:23:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 504 bytes
コンパイル時間 2,595 ms
コンパイル使用メモリ 157,148 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 21:30:56
合計ジャッジ時間 2,528 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
4,376 KB
testcase_01 AC 61 ms
4,376 KB
testcase_02 AC 30 ms
4,376 KB
testcase_03 AC 63 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void solve() {
  int n;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; ++i) {
    int l;
    cin >> l;
    ++m[l];
  }
  vector<int> v = {0, 0, 0};
  for (auto i : m) v.emplace_back(i.second);
  sort(v.rbegin(), v.rend());
  int res = 0;
  while (v[2] > 0) {
    for (int i = 0; i < 3; ++i) --v[i];
    sort(v.rbegin(), v.rend());
    ++res;
  }
  cout << res << endl;
}

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) solve();
}
0