結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | msm1993 |
提出日時 | 2020-06-02 09:50:49 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 1,495 ms |
コンパイル使用メモリ | 176,924 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-15 11:35:07 |
合計ジャッジ時間 | 2,268 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
4,380 KB |
testcase_01 | AC | 23 ms
4,376 KB |
testcase_02 | AC | 12 ms
4,376 KB |
testcase_03 | AC | 23 ms
4,380 KB |
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type] 7 | main(){ | ^~~~
ソースコード
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=int(a);i<int(b);++i) using namespace std; typedef long long ll; int INF = (1LL << 30) - 1; int MOD = 1e9+7; main(){ int T,N; cin >> T; rep(i,0,T){ cin >> N; map<int,int> mp; rep(j,0,N){ int a; scanf("%d",&a); mp[a]++; } vector<int> V; for(auto p:mp)V.push_back(p.second); sort(V.rbegin(), V.rend()); int ans = N/3; if(V.size() >= 1)ans = min(ans, (N - V[0]) / 2); if(V.size() >= 2)ans = min(ans, N - V[0] - V[1]); cout << ans << endl; } }