結果

問題 No.5 数字のブロック
コンテスト
ユーザー ちよちゃん
提出日時 2016-05-09 22:09:24
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
RE  
実行時間 -
コード長 1,102 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,547 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 48,708 KB
最終ジャッジ日時 2026-09-10 16:15:22
合計ジャッジ時間 7,408 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.Arrays;
import java.util.Scanner;

public class Yuki1 {
    
    public static void main(String[] argas) {
    
        Scanner scan = new Scanner(System.in);
        // 箱の幅
        int box = scan.nextInt();
        //int box = 16;
        // ブロックの数
        int blockCount = scan.nextInt();
        //int blockCount = 3;
        int num = scan.nextInt();
        
        int blockWidth[] = new int [num];
        //int blockWidth[] = {4,5,1,1};
        
        for (int i = 0; i <= num; i++) {
            blockWidth[i] = scan.nextInt();
        }
        
        Arrays.sort(blockWidth);
        for(int i = 0; i< 3; i++){
            System.out.println(blockWidth[i]);
        }
        
        
        int boxWidthAll = 0;
        int boxWidthAllCount = 0;
        
        while(box>boxWidthAll && blockCount>boxWidthAllCount){
            
            boxWidthAll +=blockWidth[boxWidthAllCount];

            if(box>boxWidthAll) {
                boxWidthAllCount++;
            }
        }
        
        System.out.println(boxWidthAllCount);
    }    
}
0