結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-08-25 15:46:33 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 594 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 02:17:42 |
合計ジャッジ時間 | 1,257 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:15:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&big); | ^~~~~~~~~~~~~~~~ main.c:17:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d",&amo); | ^~~~~~~~~~~~~~~~ main.c:22:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d",&small[i]); | ^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int compare(const void *a, const void *b){ return *(int*)a - *(int*)b; } int main(){ int small[10001]; int amo; int big; int sum = 0; printf("input size of bigbox :"); scanf("%d",&big); printf("input the amount of smallboxes :"); scanf("%d",&amo); printf("input size of smallboxes\n"); int i; for(i = 0; i < amo; i++){ printf("%d :",i+1); scanf("%d",&small[i]); } qsort(small, amo, sizeof(int), compare); int j = 0; while(j < amo && sum < big ){ sum += small[j++]; } printf("%d\n",j-1); return 0; }