結果

問題 No.5 数字のブロック
ユーザー phi_prog_8phi_prog_8
提出日時 2016-02-26 19:56:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 06:58:58
合計ジャッジ時間 2,524 ms
ジャッジサーバーID
(参考情報)
judge1 / 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 76 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 AC 123 ms
5,376 KB
testcase_06 AC 52 ms
5,376 KB
testcase_07 AC 35 ms
5,376 KB
testcase_08 AC 64 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 126 ms
5,376 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 82 ms
5,376 KB
testcase_13 AC 109 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 128 ms
5,376 KB
testcase_17 AC 178 ms
5,376 KB
testcase_18 AC 143 ms
5,376 KB
testcase_19 AC 198 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 0 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 0 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 0 ms
5,376 KB
testcase_28 AC 0 ms
5,376 KB
testcase_29 AC 19 ms
5,376 KB
testcase_30 AC 11 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 0 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |     ~~~~~^~~~~~~~~~~~

ソースコード

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