結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | tottoripaper |
提出日時 | 2015-03-05 00:39:12 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 779 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 42,092 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-06 13:24:51 |
合計ジャッジ時間 | 860 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
ソースコード
#include <cstdio> #include <algorithm> bool used[100]; int main(){ int T; scanf("%d", &T); while(T--){ int N; scanf("%d", &N); for(int i=0;i<N;i++){used[i] = false;} int L[100]; for(int i=0;i<N;i++){ scanf("%d", L+i); } std::sort(L, L+N); int res = 0; for(int i=0,j=0,k=0;i<N;i++){ if(used[i]){continue;} used[i] = true; while(j < N && (L[j] <= L[i] || used[j])){j++;} if(j == N){break;} while(k < N && (L[k] <= L[j] || used[k])){k++;} if(k == N){break;} used[j] = true; used[k] = true; res++; } printf("%d\n", res); } }