結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-25 16:20:45 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 21,120 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 02:22:13 |
| 合計ジャッジ時間 | 1,242 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 1 |
コンパイルメッセージ
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++];
if(j == amo){
j++;
break;
}
}
printf("%d\n",j-1);
return 0;
}