結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 128 ms
55,860 KB
testcase_02 AC 124 ms
56,092 KB
testcase_03 AC 236 ms
58,916 KB
testcase_04 AC 220 ms
59,592 KB
testcase_05 AC 247 ms
60,584 KB
testcase_06 AC 227 ms
59,368 KB
testcase_07 AC 219 ms
59,080 KB
testcase_08 AC 235 ms
59,984 KB
testcase_09 AC 201 ms
59,036 KB
testcase_10 AC 247 ms
60,180 KB
testcase_11 AC 222 ms
57,688 KB
testcase_12 AC 240 ms
59,640 KB
testcase_13 AC 251 ms
60,708 KB
testcase_14 AC 138 ms
55,768 KB
testcase_15 AC 160 ms
56,016 KB
testcase_16 AC 245 ms
59,848 KB
testcase_17 AC 258 ms
60,868 KB
testcase_18 AC 258 ms
60,376 KB
testcase_19 AC 264 ms
60,856 KB
testcase_20 AC 126 ms
55,604 KB
testcase_21 AC 126 ms
55,876 KB
testcase_22 AC 127 ms
55,900 KB
testcase_23 AC 128 ms
55,768 KB
testcase_24 AC 153 ms
56,052 KB
testcase_25 AC 173 ms
56,184 KB
testcase_26 AC 126 ms
55,912 KB
testcase_27 AC 127 ms
55,896 KB
testcase_28 AC 125 ms
55,608 KB
testcase_29 AC 221 ms
59,108 KB
testcase_30 AC 198 ms
58,540 KB
testcase_31 AC 125 ms
55,928 KB
testcase_32 AC 124 ms
55,868 KB
testcase_33 AC 124 ms
55,916 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