結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
|
提出日時 | 2018-01-08 21:16:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 1,773 ms |
コンパイル使用メモリ | 181,392 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 12:28:35 |
合計ジャッジ時間 | 2,674 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD LL(1e9 + 7) #define INF 100000000 using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PI; int main() { int t; cin >> t; vector<LL> ans; while (t--) { int n; cin >> n; map<int, int> mp; REP(i, n) { int l; cin >> l; mp[l]++; } VI v; int res = 0; for(auto e : mp) { v.push_back(e.second); } while (1) { sort(ALL(v)); reverse(ALL(v)); if (v.size() >= 3 && v[0] > 0 && v[1] > 0 && v[2] > 0) { v[0]--; v[1]--; v[2]--; res++; } else { break; } } ans.push_back(res); } for (int e : ans) cout << e << endl; return 0; }