結果
問題 |
No.120 傾向と対策:門松列(その1)
|
ユーザー |
|
提出日時 | 2018-04-12 15:19:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 5,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 1,011 ms |
コンパイル使用メモリ | 78,540 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 21:24:37 |
合計ジャッジ時間 | 1,590 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-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; } }