結果

問題 No.5 数字のブロック
ユーザー hnthnt
提出日時 2016-03-28 01:46:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 3,357 ms
コンパイル使用メモリ 74,628 KB
実行使用メモリ 58,888 KB
最終ジャッジ日時 2024-04-10 04:15:36
合計ジャッジ時間 12,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
53,864 KB
testcase_01 AC 122 ms
54,220 KB
testcase_02 WA -
testcase_03 AC 338 ms
58,796 KB
testcase_04 AC 301 ms
58,720 KB
testcase_05 WA -
testcase_06 AC 314 ms
58,608 KB
testcase_07 AC 299 ms
58,540 KB
testcase_08 AC 324 ms
58,744 KB
testcase_09 AC 217 ms
56,496 KB
testcase_10 AC 399 ms
58,676 KB
testcase_11 AC 294 ms
58,444 KB
testcase_12 AC 341 ms
58,680 KB
testcase_13 AC 374 ms
58,888 KB
testcase_14 AC 138 ms
53,968 KB
testcase_15 WA -
testcase_16 AC 382 ms
58,816 KB
testcase_17 AC 424 ms
58,700 KB
testcase_18 AC 426 ms
58,788 KB
testcase_19 AC 449 ms
58,860 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 122 ms
53,856 KB
testcase_24 AC 159 ms
54,360 KB
testcase_25 AC 175 ms
54,420 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 #

import java.util.Scanner;


public class no5 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int bigboxL=sc.nextInt();//大きな箱の幅
		int N=sc.nextInt();//ブロックの数
		int[] blockarray = new int[N];
		//小さい順にソートする
		for(int i=0;i<N;i++){
			int blockW=sc.nextInt();//各ブロックの幅
			blockarray[i]=blockW;
		}
		for(int i=0;i<blockarray.length;i++){
			for(int j=i+1;j<blockarray.length;j++){
				if(blockarray[i]>=blockarray[j]){
					int swap=blockarray[i];
					blockarray[i]=blockarray[j];
					blockarray[j]=swap;
				}
			}
		}
		for(int i=0;i<N;i++){
			bigboxL-=blockarray[i];
			if(bigboxL<=0){
				System.out.println(i);
				break;
			}else if(bigboxL<0){
				System.out.println(i--);
				break;
			}

		}
	}
}
0