結果

問題 No.5 数字のブロック
ユーザー Mcpu3Mcpu3
提出日時 2018-09-05 16:59:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 252 ms / 5,000 ms
コード長 369 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 47,796 KB
最終ジャッジ日時 2024-04-29 10:00:56
合計ジャッジ時間 8,837 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,628 KB
testcase_01 AC 113 ms
41,444 KB
testcase_02 AC 115 ms
41,628 KB
testcase_03 AC 229 ms
46,304 KB
testcase_04 AC 204 ms
45,800 KB
testcase_05 AC 234 ms
47,104 KB
testcase_06 AC 205 ms
45,932 KB
testcase_07 AC 202 ms
45,948 KB
testcase_08 AC 221 ms
45,752 KB
testcase_09 AC 180 ms
43,596 KB
testcase_10 AC 234 ms
46,716 KB
testcase_11 AC 198 ms
46,320 KB
testcase_12 AC 220 ms
46,080 KB
testcase_13 AC 234 ms
46,192 KB
testcase_14 AC 131 ms
41,884 KB
testcase_15 AC 137 ms
41,896 KB
testcase_16 AC 229 ms
46,764 KB
testcase_17 AC 241 ms
47,796 KB
testcase_18 AC 238 ms
47,756 KB
testcase_19 AC 252 ms
47,748 KB
testcase_20 AC 116 ms
41,148 KB
testcase_21 AC 106 ms
41,488 KB
testcase_22 AC 108 ms
41,392 KB
testcase_23 AC 120 ms
41,060 KB
testcase_24 AC 146 ms
41,644 KB
testcase_25 AC 159 ms
42,640 KB
testcase_26 AC 113 ms
41,160 KB
testcase_27 AC 120 ms
41,200 KB
testcase_28 AC 119 ms
41,576 KB
testcase_29 AC 198 ms
45,672 KB
testcase_30 AC 189 ms
43,924 KB
testcase_31 AC 135 ms
41,392 KB
testcase_32 AC 132 ms
41,708 KB
testcase_33 AC 108 ms
41,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int l=sc.nextInt(),n=sc.nextInt(),w[]=new int[n],t=0,i;
		for(i=0;i<n;++i) w[i]=sc.nextInt();
		sc.close();
		Arrays.sort(w);
		for(i=0;i<n;++i) {
			t+=w[i];
			if(t>l) break;
		}
		System.out.print(i);
	}
}
0