結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-03-05 00:32:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 746 bytes |
| コンパイル時間 | 438 ms |
| コンパイル使用メモリ | 37,472 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 07:59:33 |
| 合計ジャッジ時間 | 901 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d", &T);
| ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:18:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d", L+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#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++;}
while(k < N && (L[k] <= L[j] || used[k])){k++;}
if(j == N || k == N){break;}
used[j] = true;
used[k] = true;
res++;
}
printf("%d\n", res);
}
}
tottoripaper