結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2017-03-01 10:13:49 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 180 ms / 5,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 139 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 10:54:17 |
合計ジャッジ時間 | 2,246 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d%d",&BoxW,&N); | ^~~~~~~~~~~~~~~~~~~~~~ main.c:11:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",&BlockW[i]); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int BoxW,N,BlockW[10000],i; scanf("%d%d",&BoxW,&N); for(i=0;i<N;i++){ scanf("%d",&BlockW[i]); } int j,temp; for(i=0;i<N;i++){ /*昇順並び替え*/ for(j=i+1;j<N;j++){ if( BlockW[i] > BlockW[j] ){ temp= BlockW[i]; BlockW[i]=BlockW[j]; BlockW[j]=temp; } } } //for(i=0;i<N;i++) /*並び替え確認*/ //printf("%d\n",BlockW[i]); int total=0; int count=0; for(i=0;i<N;i++){ if(total <= BoxW){ total = total + BlockW[i]; } if(total <= BoxW){ count++; } } printf("%d\n",count); return 0; }