結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-05-09 22:02:08 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 3,665 ms |
コンパイル使用メモリ | 74,840 KB |
実行使用メモリ | 45,844 KB |
最終ジャッジ日時 | 2024-10-05 13:17:03 |
合計ジャッジ時間 | 10,797 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 34 |
ソースコード
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); } }