結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:22:00
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 476 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 71,608 KB
実行使用メモリ 60,604 KB
最終ジャッジ日時 2023-08-30 02:43:03
合計ジャッジ時間 9,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,672 KB
testcase_01 AC 125 ms
56,072 KB
testcase_02 RE -
testcase_03 AC 231 ms
59,872 KB
testcase_04 AC 208 ms
59,508 KB
testcase_05 AC 246 ms
59,900 KB
testcase_06 AC 225 ms
59,496 KB
testcase_07 AC 217 ms
59,088 KB
testcase_08 AC 221 ms
59,496 KB
testcase_09 AC 201 ms
56,724 KB
testcase_10 AC 248 ms
60,352 KB
testcase_11 AC 218 ms
59,836 KB
testcase_12 AC 247 ms
60,532 KB
testcase_13 AC 240 ms
59,832 KB
testcase_14 AC 137 ms
55,952 KB
testcase_15 AC 154 ms
56,128 KB
testcase_16 AC 245 ms
59,900 KB
testcase_17 AC 255 ms
60,112 KB
testcase_18 AC 253 ms
60,328 KB
testcase_19 AC 260 ms
60,604 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 124 ms
56,112 KB
testcase_24 AC 151 ms
56,192 KB
testcase_25 AC 183 ms
56,260 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 207 ms
59,296 KB
testcase_30 AC 198 ms
58,564 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L=sc.nextInt();
		int N = sc.nextInt();
		int[] block = new int[N];
		for(int i=0;i<N;i++){
			block[i]=sc.nextInt();
		}
		Arrays.sort(block);
		int sum=0;
		int ans=0;
		int iti=0;
		while(sum<=L){
			if(iti<=N){
			sum+=block[iti];
			iti++;
			ans++;
			}else{
				break;
			}
		}
		System.out.println(ans-1);
	}
}	
0