結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2025-03-10 13:54:39 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 509 bytes |
コンパイル時間 | 542 ms |
コンパイル使用メモリ | 25,472 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-10 13:54:41 |
合計ジャッジ時間 | 2,102 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | AC * 3 WA * 27 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:5:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:6:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&m); | ^~~~~~~~~~~~~~ main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&candyBox[i]); | ^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> void main(void){ int n = 0,m = 0; scanf("%d",&n); scanf("%d",&m); int candyBox[n]; for(int i = 0 ; i < n ; i ++){ scanf("%d",&candyBox[i]); } for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < n ; j++){ if(candyBox[i] < candyBox[j]){ int num = candyBox[i]; candyBox[i] = candyBox[j]; candyBox[j] = num; } } } int nullBox = 0; for(int i = 0 ; i < n ; i++){ n -= candyBox[i]; if(n >= 0){ nullBox++; }else{ break; } } printf("%d",nullBox); }