結果

問題 No.5 数字のブロック
ユーザー Mcpu3Mcpu3
提出日時 2018-09-05 16:58:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 254 ms / 5,000 ms
コード長 397 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 74,432 KB
実行使用メモリ 47,832 KB
最終ジャッジ日時 2024-04-29 10:00:34
合計ジャッジ時間 8,495 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
41,608 KB
testcase_01 AC 112 ms
40,944 KB
testcase_02 AC 117 ms
41,296 KB
testcase_03 AC 217 ms
46,496 KB
testcase_04 AC 198 ms
45,696 KB
testcase_05 AC 229 ms
46,336 KB
testcase_06 AC 209 ms
45,748 KB
testcase_07 AC 198 ms
45,408 KB
testcase_08 AC 215 ms
46,444 KB
testcase_09 AC 184 ms
43,220 KB
testcase_10 AC 222 ms
47,832 KB
testcase_11 AC 186 ms
45,972 KB
testcase_12 AC 226 ms
46,848 KB
testcase_13 AC 232 ms
46,652 KB
testcase_14 AC 129 ms
41,868 KB
testcase_15 AC 133 ms
42,048 KB
testcase_16 AC 234 ms
47,128 KB
testcase_17 AC 241 ms
47,448 KB
testcase_18 AC 248 ms
47,768 KB
testcase_19 AC 254 ms
47,772 KB
testcase_20 AC 107 ms
41,324 KB
testcase_21 AC 120 ms
41,120 KB
testcase_22 AC 117 ms
41,472 KB
testcase_23 AC 105 ms
40,068 KB
testcase_24 AC 143 ms
41,612 KB
testcase_25 AC 157 ms
41,708 KB
testcase_26 AC 102 ms
41,480 KB
testcase_27 AC 107 ms
41,376 KB
testcase_28 AC 121 ms
41,036 KB
testcase_29 AC 204 ms
45,900 KB
testcase_30 AC 184 ms
43,548 KB
testcase_31 AC 108 ms
41,172 KB
testcase_32 AC 115 ms
41,272 KB
testcase_33 AC 114 ms
41,060 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],s=0,t=0,i;
		for(i=0;i<n;++i) {
			w[i]=sc.nextInt();
			s+=w[i];
		}
		sc.close();
		Arrays.sort(w);
		for(i=0;i<n;++i) {
			t+=w[i];
			if(t>l) break;
		}
		System.out.print(i);
	}
}
0