結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | hotpepsi |
提出日時 | 2015-01-10 00:29:47 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 45 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 765 ms |
コンパイル使用メモリ | 67,568 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-03 22:54:03 |
合計ジャッジ時間 | 1,481 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
4,376 KB |
testcase_01 | AC | 44 ms
4,376 KB |
testcase_02 | AC | 22 ms
4,376 KB |
testcase_03 | AC | 45 ms
4,380 KB |
ソースコード
#include <iostream> #include <algorithm> #include <sstream> #include <vector> using namespace std; int main(int argc, char *argv[]) { string s; getline(cin, s); int T = atoi(s.c_str()); for (int t = 0; t < T; ++t) { getline(cin, s); int N = atoi(s.c_str()); getline(cin, s); stringstream ss(s); int n[100] = {}; for (int i = 0; i < N; ++i) { ss >> n[i]; } sort(n, n + N); int c = 1; int cnt[100] = { 1 }; for (int i = 1; i < N; ++i) { if (n[i - 1] != n[i]) { ++c; } cnt[c - 1] += 1; } int ans = 0; if (c >= 3) { while (true) { sort(cnt, cnt + c); if (cnt[c - 3] <= 0) { break; } ++ans; cnt[c - 3] -= 1, cnt[c - 2] -= 1, cnt[c - 1] -= 1; } } cout << ans << endl; } return 0; }