結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-23 18:03:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 5,000 ms |
| コード長 | 1,094 bytes |
| コンパイル時間 | 902 ms |
| コンパイル使用メモリ | 88,188 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 00:03:07 |
| 合計ジャッジ時間 | 1,497 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int t;
std::cin >> t;
for(int i=0; i<t; ++i){
int n;
std::cin >> n;
std::map<int, int> lNumMap;
for(int j=0; j<n; ++j){
int input;
std::cin >> input;
++lNumMap[input];
}
std::vector<std::pair<int, int>> lNumPair(2, std::make_pair(0, 0));
for(auto it=lNumMap.begin(); it!=lNumMap.end(); ++it){
lNumPair.push_back(std::make_pair(it->first, it->second));
}
int ans = 0;
while(true){
std::sort(lNumPair.begin(), lNumPair.end(), [](const std::pair<int, int>& l, const std::pair<int, int>& r){
return l.second>r.second;
});
if(lNumPair[2].second==0) break;
for(int j=0; j<3; ++j){
--lNumPair[j].second;
}
++ans;
}
std::cout << ans << "\n";
}
return 0;
}