結果

問題 No.5 数字のブロック
ユーザー omc-testomc-test
提出日時 2016-08-03 13:05:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 75,928 KB
実行使用メモリ 48,044 KB
最終ジャッジ日時 2024-04-24 15:12:27
合計ジャッジ時間 9,439 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
40,112 KB
testcase_01 AC 122 ms
40,876 KB
testcase_02 WA -
testcase_03 AC 231 ms
46,220 KB
testcase_04 AC 221 ms
46,228 KB
testcase_05 WA -
testcase_06 AC 221 ms
46,236 KB
testcase_07 AC 221 ms
46,020 KB
testcase_08 AC 237 ms
46,760 KB
testcase_09 AC 197 ms
43,652 KB
testcase_10 AC 257 ms
47,160 KB
testcase_11 AC 217 ms
45,936 KB
testcase_12 AC 241 ms
46,424 KB
testcase_13 AC 259 ms
46,916 KB
testcase_14 AC 133 ms
41,272 KB
testcase_15 WA -
testcase_16 AC 255 ms
47,136 KB
testcase_17 AC 278 ms
47,788 KB
testcase_18 AC 270 ms
47,872 KB
testcase_19 AC 300 ms
48,044 KB
testcase_20 AC 130 ms
40,904 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 114 ms
39,948 KB
testcase_24 AC 145 ms
41,900 KB
testcase_25 AC 171 ms
42,332 KB
testcase_26 AC 118 ms
41,068 KB
testcase_27 AC 106 ms
39,844 KB
testcase_28 AC 116 ms
39,980 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 127 ms
41,160 KB
testcase_32 AC 118 ms
41,236 KB
testcase_33 AC 117 ms
40,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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();
		List<Integer> w = new ArrayList<Integer>();
		for(int i=0; i<n; i++){
			w.add(sc.nextInt());
		}
		sc.close();
		Collections.sort(w);
		int sum = 0;
		int count;
		for(count = 0; count<w.size(); count++){
			if(l > sum + w.get(count)){
				sum = sum + w.get(count);
			}else{
				break;
			}
		}
		System.out.println(count);
	}
}
0