結果

問題 No.5 数字のブロック
ユーザー GBGB
提出日時 2018-04-09 14:11:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 781 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 73,828 KB
実行使用メモリ 60,564 KB
最終ジャッジ日時 2023-09-09 03:25:02
合計ジャッジ時間 11,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,720 KB
testcase_01 AC 122 ms
55,684 KB
testcase_02 WA -
testcase_03 AC 318 ms
60,180 KB
testcase_04 AC 294 ms
59,872 KB
testcase_05 AC 362 ms
60,108 KB
testcase_06 AC 296 ms
60,172 KB
testcase_07 AC 288 ms
59,784 KB
testcase_08 AC 310 ms
60,332 KB
testcase_09 AC 206 ms
56,864 KB
testcase_10 AC 381 ms
60,412 KB
testcase_11 AC 286 ms
59,852 KB
testcase_12 AC 329 ms
59,844 KB
testcase_13 AC 356 ms
60,080 KB
testcase_14 AC 125 ms
55,544 KB
testcase_15 AC 135 ms
55,808 KB
testcase_16 AC 368 ms
60,564 KB
testcase_17 AC 408 ms
60,212 KB
testcase_18 AC 387 ms
60,464 KB
testcase_19 AC 419 ms
60,060 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 121 ms
55,880 KB
testcase_24 AC 141 ms
55,832 KB
testcase_25 AC 174 ms
56,280 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 293 ms
59,976 KB
testcase_30 AC 227 ms
57,492 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) {

    Scanner scan=new Scanner(System.in);
    int l=Integer.parseInt(scan.next());
    int n=Integer.parseInt(scan.next());
    int[] w=new int[n];
    for(int i=0;i<w.length;i++){
      w[i]=Integer.parseInt(scan.next());
    }

    for (int i = 0; i < w.length - 1; i++) {
            for (int j = w.length - 1; j > i; j--) {
                if (w[j - 1] > w[j]) {
                    int tmp = w[j - 1];
                    w[j - 1] = w[j];
                    w[j] = tmp;
                }
            }
        }

    int count=0;
    for(int i=0;i<w.length-1;i++){
      l-=w[i];
      count++;
      if(l<w[i+1]){
        break;
      }
    }

    System.out.println(count);
  }
}
0