結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
youjo_yamioti
|
| 提出日時 | 2018-12-09 01:48:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,578 bytes |
| コンパイル時間 | 1,517 ms |
| コンパイル使用メモリ | 162,424 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 07:20:22 |
| 合計ジャッジ時間 | 3,195 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int search(vector<int> vec,int n){
for(int i=0;i<vec.size();i++){
if(vec[i] == n) return i;
}
return -1;
}
int not0count(vector<int> vec){
int ans = 0;
for(int i=0;i<vec.size();i++){
if(vec[i] != 0) ans++;
}
return ans;
}
int main(){
int T;
int N;
int c;
int p = 0;
cin >> T;
for(int i=0;i<T;i++){
vector<int> num(N,0),count(N,0);
int ans=0;
cin >> N;
for(int j=0;j<N;j++){
cin >> c;
if(search(num,c) != -1){
count[search(num,c)]++;
}else{
num[p] = c;
count[p] = 1;
p++;
}
}
int sum = 0;
for(int j=0;j<N;j++) sum += count[j];
while(sum >= 3 && not0count(count) >= 2){
vector<int> flag(N,0);
for(int j=0;j<3;j++){
vector<int>::iterator it = max_element(count.begin(),count.end());
int maxindex = distance(count.begin(),it);
if(flag[maxindex] != 2){
count[maxindex]--;
flag[maxindex]++;
}else{
vector<int> temp = count;
temp[maxindex] = 0;
it = max_element(temp.begin(),temp.end());
int maxindex2 = distance(count.begin(),it);
count[maxindex2]--;
}
}
ans++;
}
cout << ans << endl;
}
return 0;
}
youjo_yamioti