結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-02-26 19:55:40 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 197 ms / 5,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 140 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 14:00:36 |
合計ジャッジ時間 | 2,529 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&L); | ^~~~~~~~~~~~~~ main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:12:5: warning: ignoring return value of ‘scanf’ 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; }