結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
![]() |
提出日時 | 2024-11-02 18:11:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,272 bytes |
コンパイル時間 | 3,733 ms |
コンパイル使用メモリ | 257,988 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-02 18:11:59 |
合計ジャッジ時間 | 4,741 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 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 rFor(i, a, b) for(int i = a; i >= b; i--)#define ALL(v) (v).begin(), (v).end()#define rALL(v) (v).rbegin(), (v).rend()using namespace std;using lint = long long;using ld = long double;int INF = 2000000000;lint LINF = 1000000000000000000;int main() {int t;cin >> t;while (t--) {int n;cin >> n;map<int, int> mp;rep(_, n) {int l;cin >> l;mp[l]++;}set<int> s;for (auto [fi, se] : mp) {if (!s.count(fi)) {s.insert(fi);}}int ans = 0;while ((int)s.size() >= 3) {auto it = s.begin();int a = *it;it = next(it);int b = *it;it = next(it);int c = *it;ans++;mp[a]--;if (mp[a] == 0) {s.erase(a);}mp[b]--;if (mp[b] == 0) {s.erase(b);}mp[c]--;if (mp[c] == 0) {s.erase(c);}}cout << ans << endl;}}