結果

問題 No.5 数字のブロック
ユーザー kanra661kanra661
提出日時 2014-12-16 16:17:41
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 449 bytes
コンパイル時間 5,375 ms
コンパイル使用メモリ 71,268 KB
実行使用メモリ 60,840 KB
最終ジャッジ日時 2023-09-02 15:19:42
合計ジャッジ時間 11,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,736 KB
testcase_01 AC 128 ms
55,864 KB
testcase_02 RE -
testcase_03 AC 237 ms
59,900 KB
testcase_04 AC 219 ms
59,568 KB
testcase_05 AC 250 ms
60,368 KB
testcase_06 AC 223 ms
59,160 KB
testcase_07 AC 225 ms
60,840 KB
testcase_08 AC 235 ms
59,716 KB
testcase_09 AC 202 ms
58,224 KB
testcase_10 AC 258 ms
60,064 KB
testcase_11 AC 221 ms
59,364 KB
testcase_12 AC 242 ms
59,804 KB
testcase_13 AC 255 ms
60,408 KB
testcase_14 AC 143 ms
55,612 KB
testcase_15 AC 159 ms
55,980 KB
testcase_16 AC 252 ms
60,396 KB
testcase_17 AC 252 ms
60,128 KB
testcase_18 AC 272 ms
60,716 KB
testcase_19 AC 266 ms
60,680 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 127 ms
55,500 KB
testcase_24 AC 154 ms
55,792 KB
testcase_25 AC 186 ms
56,480 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 224 ms
59,476 KB
testcase_30 AC 202 ms
58,584 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int n = sc.nextInt();
		int w[] = new int[n];
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
		}
		Arrays.sort(w);
		int now_wide = 0;
		int i = 0;
		while(l >= now_wide + w[i] && n>i){
			now_wide += w[i];
			i++;
		}
		System.out.println(i);
	}
}
0