結果

問題 No.5 数字のブロック
ユーザー shallowshallow
提出日時 2017-08-30 22:05:24
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 07:21:56
合計ジャッジ時間 2,295 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 69 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 45 ms
5,376 KB
testcase_07 AC 31 ms
5,376 KB
testcase_08 AC 54 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 106 ms
5,376 KB
testcase_11 AC 26 ms
5,376 KB
testcase_12 AC 71 ms
5,376 KB
testcase_13 AC 93 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 110 ms
5,376 KB
testcase_17 AC 152 ms
5,376 KB
testcase_18 AC 123 ms
5,376 KB
testcase_19 AC 172 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int main() {
  int L, N, W[10000] = {0}, i, j, tmp, x;
  scanf("%d %d", &L, &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &W[i]);
  }
  for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
      if (W[i] > W[j] && j != N) {
        tmp = W[i];
        W[i] = W[j];
        W[j] = tmp;
      }
    }
  }
  for (i = 0; i < N; i++) {
    if (N == 1 && W[0] <= L) {
      printf("%d\n", W[0]);
      break;
    }
    x += W[i];
    if (x >= L) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
0