結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-07-01 14:18:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 493 bytes |
コンパイル時間 | 308 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 01:10:31 |
合計ジャッジ時間 | 2,517 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&L); | ~~~~~^~~~~~~~~ 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:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d",&W[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:30:30: warning: ‘judge’ may be used uninitialized [-Wmaybe-uninitialized] 30 | for(k=0;judge>0;++k){ | ~~~~~^~
ソースコード
#include<stdio.h> int main() { int L,N,W[10000]; int i,j,k; int tmp; int sum=0; int judge; //入力 scanf("%d",&L); scanf("%d",&N); for(i=0;i<N;++i){ scanf("%d",&W[i]); } //並び替え(小さい順) for(i=0;i<N;++i){ for(j=i+1;j<N;++j){ if(W[i]>W[j]){ tmp=W[i]; W[i]=W[j]; W[j]=tmp; } } } //判定 if(L==W[0]){ k=1; }else{ for(k=0;judge>0;++k){ sum=sum+W[k]; judge=L-sum; } if(judge<0) k=k-1; } //出力 printf("%d",k); return 0; }