結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-02-26 19:56:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 197 ms / 5,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:17:24 |
合計ジャッジ時間 | 2,496 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&L); | ~~~~~^~~~~~~~~ main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d",&W[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int L; int n; int W[10000] = { 0 }; int temp; scanf("%d",&L); scanf("%d",&n); for (int i = 0; i < n; i++) { scanf("%d",&W[i]); } //<<<<< for (int i = 0; i < n-1; i++) { for (int j = i+1; j < n; j++) { if (W[i] > W[j]) { temp = W[i]; W[i] = W[j]; W[j] = temp; } } } int sum=0; int i; for (i=0; i<n; i++) { sum+=W[i]; if (sum>L) break; } printf("%d\n",i); return 0; }