結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-08 23:57:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,166 bytes |
| コンパイル時間 | 816 ms |
| コンパイル使用メモリ | 65,364 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-13 03:23:13 |
| 合計ジャッジ時間 | 1,381 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int BUF = 105;
int N;
int vList[BUF];
void read() {
cin >> N;
for (int i = 0; i < N; ++i)
cin >> vList[i];
}
void work() {
sort(vList, vList + N);
vector<int> cntList;
for (int idx = 0; idx < N; ++idx) {
int cnt = 1;
while (idx + 1 < N && vList[idx + 1] == vList[idx]) {
++idx;
++cnt;
}
cntList.push_back(cnt);
}
int ans = 0;
while (cntList.size() >= 3) {
if (cntList[0] == 0) {
cntList.erase(cntList.begin());
continue;
}
if (cntList[1] == 0) {
cntList.erase(cntList.begin() + 1);
continue;
}
if (cntList[2] == 0) {
cntList.erase(cntList.begin() + 2);
continue;
}
--cntList[0];
--cntList[1];
--cntList[2];
++ans;
}
cout << ans << endl;
}
int main() {
int cases;
cin >> cases;
for (int i = 0; i < cases; ++i) {
read();
work();
}
return 0;
}