結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-01-10 00:29:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 764 bytes |
| コンパイル時間 | 666 ms |
| コンパイル使用メモリ | 66,620 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-13 03:31:54 |
| 合計ジャッジ時間 | 1,332 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#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;
}
hotpepsi