結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2025-03-26 14:53:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 27,776 KB |
実行使用メモリ | 7,328 KB |
最終ジャッジ日時 | 2025-03-26 14:53:44 |
合計ジャッジ時間 | 3,022 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d",&block,&box); | ~~~~~^~~~~~~~~~~~~~~~~~~~ main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&tolerance[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(){ // ブロック数・箱数 int block,box; scanf("%d%d",&block,&box); // 1つの箱にブロックが入る数 int tolerance[box]; for(int i = 0;i < box;i ++){ scanf("%d",&tolerance[i]); } // ソート for(int i = 0;i < box;i ++){ for(int j = 0;j < box;j ++){ if(tolerance[i] < tolerance[j]){ int tmp = tolerance[i]; tolerance[i] = tolerance[j]; tolerance[j] = tmp; } } } int now = 0; int count = 0; while(now < block){ now += tolerance[count]; count++; } printf("%d",count); }