結果

問題 No.5 数字のブロック
ユーザー m2543315647m2543315647
提出日時 2015-05-13 08:40:08
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 430 bytes
コンパイル時間 5,627 ms
コンパイル使用メモリ 72,536 KB
実行使用メモリ 60,492 KB
最終ジャッジ日時 2023-09-20 04:49:06
合計ジャッジ時間 12,392 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,852 KB
testcase_01 AC 130 ms
56,060 KB
testcase_02 AC 129 ms
55,688 KB
testcase_03 AC 238 ms
59,528 KB
testcase_04 AC 215 ms
59,396 KB
testcase_05 AC 253 ms
60,492 KB
testcase_06 AC 229 ms
44,604 KB
testcase_07 AC 215 ms
46,192 KB
testcase_08 AC 226 ms
46,784 KB
testcase_09 AC 201 ms
43,820 KB
testcase_10 AC 253 ms
44,848 KB
testcase_11 AC 224 ms
46,008 KB
testcase_12 AC 246 ms
45,716 KB
testcase_13 AC 252 ms
44,400 KB
testcase_14 AC 141 ms
42,980 KB
testcase_15 AC 158 ms
39,784 KB
testcase_16 AC 249 ms
44,484 KB
testcase_17 AC 265 ms
46,764 KB
testcase_18 AC 259 ms
46,436 KB
testcase_19 AC 261 ms
46,672 KB
testcase_20 WA -
testcase_21 AC 126 ms
39,824 KB
testcase_22 WA -
testcase_23 AC 123 ms
39,488 KB
testcase_24 AC 158 ms
40,252 KB
testcase_25 AC 182 ms
40,164 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 220 ms
43,788 KB
testcase_30 AC 200 ms
44,612 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No5 {
	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];
		int sum=0;
		for(int i=0;i<n;i++)
			w[i]=sc.nextInt();
		Arrays.sort(w);
		for(int i=0;i<n;i++)
		{
			sum+=w[i];
			if(sum>l)
			{
				System.out.println(i);
				return;
			}
		}
		System.out.println(l);
	}
}
0