結果

問題 No.5 数字のブロック
ユーザー kou6839kou6839
提出日時 2014-11-08 16:17:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 72,736 KB
実行使用メモリ 62,340 KB
最終ジャッジ日時 2023-08-30 02:42:40
合計ジャッジ時間 10,001 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 130 ms
55,856 KB
testcase_02 AC 129 ms
55,972 KB
testcase_03 AC 234 ms
60,028 KB
testcase_04 AC 220 ms
59,300 KB
testcase_05 AC 250 ms
60,076 KB
testcase_06 AC 231 ms
59,812 KB
testcase_07 AC 222 ms
61,008 KB
testcase_08 AC 237 ms
59,204 KB
testcase_09 AC 207 ms
58,488 KB
testcase_10 AC 253 ms
60,292 KB
testcase_11 AC 222 ms
59,576 KB
testcase_12 AC 239 ms
59,452 KB
testcase_13 AC 246 ms
60,944 KB
testcase_14 AC 140 ms
55,592 KB
testcase_15 AC 152 ms
53,828 KB
testcase_16 AC 250 ms
62,340 KB
testcase_17 AC 262 ms
60,656 KB
testcase_18 AC 264 ms
60,144 KB
testcase_19 AC 281 ms
60,452 KB
testcase_20 AC 128 ms
55,900 KB
testcase_21 AC 127 ms
55,824 KB
testcase_22 AC 128 ms
56,212 KB
testcase_23 AC 127 ms
56,060 KB
testcase_24 AC 154 ms
56,356 KB
testcase_25 AC 177 ms
56,712 KB
testcase_26 AC 128 ms
55,904 KB
testcase_27 AC 127 ms
55,976 KB
testcase_28 AC 126 ms
56,116 KB
testcase_29 AC 209 ms
59,132 KB
testcase_30 AC 203 ms
58,512 KB
testcase_31 AC 126 ms
55,824 KB
testcase_32 AC 129 ms
55,576 KB
testcase_33 AC 127 ms
55,820 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(sum<=L){
			sum+=block[iti];
			iti++;
			ans++;
			if(iti==N){
				ans++;
				break;
			}
		}
		System.out.println(ans-1);
	}
}	
0