結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:24:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 71,712 KB
実行使用メモリ 60,720 KB
最終ジャッジ日時 2023-08-30 02:43:25
合計ジャッジ時間 9,969 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 123 ms
55,876 KB
testcase_02 AC 124 ms
55,696 KB
testcase_03 AC 237 ms
59,832 KB
testcase_04 AC 215 ms
59,584 KB
testcase_05 AC 243 ms
59,952 KB
testcase_06 AC 223 ms
59,784 KB
testcase_07 AC 211 ms
59,400 KB
testcase_08 AC 230 ms
59,392 KB
testcase_09 AC 197 ms
58,344 KB
testcase_10 AC 250 ms
59,424 KB
testcase_11 AC 216 ms
59,476 KB
testcase_12 AC 237 ms
59,784 KB
testcase_13 AC 250 ms
60,692 KB
testcase_14 AC 139 ms
55,856 KB
testcase_15 AC 153 ms
55,948 KB
testcase_16 AC 250 ms
60,168 KB
testcase_17 AC 255 ms
60,508 KB
testcase_18 AC 252 ms
60,340 KB
testcase_19 AC 253 ms
60,720 KB
testcase_20 AC 123 ms
55,956 KB
testcase_21 AC 124 ms
55,720 KB
testcase_22 AC 124 ms
55,952 KB
testcase_23 AC 126 ms
55,700 KB
testcase_24 AC 152 ms
56,072 KB
testcase_25 AC 180 ms
56,572 KB
testcase_26 AC 123 ms
55,720 KB
testcase_27 AC 125 ms
56,200 KB
testcase_28 AC 122 ms
55,788 KB
testcase_29 AC 209 ms
59,188 KB
testcase_30 AC 195 ms
58,392 KB
testcase_31 AC 123 ms
55,692 KB
testcase_32 AC 123 ms
56,000 KB
testcase_33 AC 126 ms
55,784 KB
権限があれば一括ダウンロードができます

ソースコード

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(true){
			sum+=block[iti];
			iti++;
			ans++;
			if(iti==N){
				System.out.println(ans);
				return;
			}else if(sum>L){
				System.out.println(ans-1);
				return;
			}
		}
	}
}	
0