結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | kotatsugame |
提出日時 | 2018-04-12 15:19:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 764 ms |
コンパイル使用メモリ | 78,216 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-09 04:17:13 |
合計ジャッジ時間 | 1,580 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
4,380 KB |
testcase_01 | AC | 44 ms
4,376 KB |
testcase_02 | AC | 24 ms
4,376 KB |
testcase_03 | AC | 44 ms
4,376 KB |
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; int t; main() { cin>>t; for(;t--;) { int n,l[1000]; cin>>n; for(int i=0;i<n;i++)cin>>l[i]; sort(l,l+n); vector<int>a; int cnt=1,f=l[0]; for(int i=1;i<n;i++) { if(f==l[i])cnt++; else { a.push_back(cnt); cnt=1; f=l[i]; } } a.push_back(cnt); sort(a.begin(),a.end(),greater<int>()); if(a.size()<3) { cout<<0<<endl; } else if(a[0]<=n/3) { cout<<n/3<<endl; } else if(a[1]<=(n-a[0])/2) { cout<<(n-a[0])/2<<endl; } else cout<<(n-a[0]-a[1])<<endl; } }