結果

問題 No.5 数字のブロック
ユーザー hnthnt
提出日時 2016-03-28 02:14:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 452 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 4,484 ms
コンパイル使用メモリ 74,528 KB
実行使用メモリ 60,580 KB
最終ジャッジ日時 2023-08-11 14:53:11
合計ジャッジ時間 12,995 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,680 KB
testcase_01 AC 127 ms
55,748 KB
testcase_02 AC 128 ms
55,636 KB
testcase_03 AC 350 ms
60,224 KB
testcase_04 AC 298 ms
60,112 KB
testcase_05 AC 405 ms
60,124 KB
testcase_06 AC 345 ms
60,580 KB
testcase_07 AC 288 ms
60,368 KB
testcase_08 AC 332 ms
59,724 KB
testcase_09 AC 217 ms
58,500 KB
testcase_10 AC 393 ms
60,144 KB
testcase_11 AC 320 ms
60,120 KB
testcase_12 AC 353 ms
59,956 KB
testcase_13 AC 378 ms
60,188 KB
testcase_14 AC 141 ms
55,536 KB
testcase_15 AC 155 ms
55,612 KB
testcase_16 AC 407 ms
60,080 KB
testcase_17 AC 448 ms
60,092 KB
testcase_18 AC 442 ms
59,920 KB
testcase_19 AC 452 ms
60,064 KB
testcase_20 AC 128 ms
55,396 KB
testcase_21 AC 126 ms
55,624 KB
testcase_22 AC 126 ms
55,768 KB
testcase_23 AC 127 ms
55,892 KB
testcase_24 AC 155 ms
55,668 KB
testcase_25 AC 195 ms
56,096 KB
testcase_26 AC 126 ms
55,900 KB
testcase_27 AC 126 ms
55,648 KB
testcase_28 AC 126 ms
55,692 KB
testcase_29 AC 298 ms
59,904 KB
testcase_30 AC 231 ms
58,644 KB
testcase_31 AC 126 ms
55,776 KB
testcase_32 AC 128 ms
55,644 KB
testcase_33 AC 126 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

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;
				}
			}
		}
		int cnt=0;
		boolean flag=false;
		for(int i=0;i<N;i++){
			bigboxL-=blockarray[i];
			if(bigboxL>=0)cnt++;
			if(bigboxL<=0){
				flag=false;
				System.out.println(cnt);
				break;
			}else if(bigboxL<0){
				flag=false;
				System.out.println(cnt);
				break;
			}else{
				flag=true;
			}
		}
		if(flag){
			System.out.println(cnt);
		}
	}
}
0