結果

問題 No.5 数字のブロック
ユーザー phi_prog_8phi_prog_8
提出日時 2016-02-26 19:55:40
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 197 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 21,856 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 20:21:02
合計ジャッジ時間 2,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 78 ms
4,348 KB
testcase_04 AC 20 ms
4,348 KB
testcase_05 AC 123 ms
4,348 KB
testcase_06 AC 52 ms
4,348 KB
testcase_07 AC 35 ms
4,348 KB
testcase_08 AC 63 ms
4,348 KB
testcase_09 AC 9 ms
4,348 KB
testcase_10 AC 125 ms
4,348 KB
testcase_11 AC 31 ms
4,348 KB
testcase_12 AC 82 ms
4,348 KB
testcase_13 AC 110 ms
4,348 KB
testcase_14 AC 0 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 128 ms
4,348 KB
testcase_17 AC 178 ms
4,348 KB
testcase_18 AC 144 ms
4,348 KB
testcase_19 AC 197 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 0 ms
4,348 KB
testcase_24 AC 0 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 0 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 19 ms
4,348 KB
testcase_30 AC 11 ms
4,348 KB
testcase_31 AC 0 ms
4,348 KB
testcase_32 AC 0 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |     ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0