結果

問題 No.5 数字のブロック
ユーザー kanra661kanra661
提出日時 2014-12-16 16:29:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 283 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 2,154 ms
コンパイル使用メモリ 75,052 KB
実行使用メモリ 47,456 KB
最終ジャッジ日時 2024-04-29 00:28:53
合計ジャッジ時間 9,901 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,448 KB
testcase_01 AC 136 ms
41,308 KB
testcase_02 AC 137 ms
41,256 KB
testcase_03 AC 249 ms
46,856 KB
testcase_04 AC 228 ms
45,740 KB
testcase_05 AC 267 ms
47,172 KB
testcase_06 AC 240 ms
46,248 KB
testcase_07 AC 233 ms
45,744 KB
testcase_08 AC 247 ms
46,328 KB
testcase_09 AC 210 ms
43,684 KB
testcase_10 AC 262 ms
47,280 KB
testcase_11 AC 227 ms
45,980 KB
testcase_12 AC 257 ms
46,880 KB
testcase_13 AC 259 ms
47,164 KB
testcase_14 AC 149 ms
41,668 KB
testcase_15 AC 156 ms
41,956 KB
testcase_16 AC 262 ms
47,352 KB
testcase_17 AC 270 ms
47,408 KB
testcase_18 AC 278 ms
47,456 KB
testcase_19 AC 283 ms
47,296 KB
testcase_20 AC 136 ms
41,352 KB
testcase_21 AC 137 ms
41,048 KB
testcase_22 AC 135 ms
41,048 KB
testcase_23 AC 135 ms
41,396 KB
testcase_24 AC 163 ms
41,476 KB
testcase_25 AC 188 ms
42,144 KB
testcase_26 AC 135 ms
41,080 KB
testcase_27 AC 136 ms
41,352 KB
testcase_28 AC 134 ms
41,120 KB
testcase_29 AC 225 ms
46,044 KB
testcase_30 AC 215 ms
43,984 KB
testcase_31 AC 139 ms
41,036 KB
testcase_32 AC 136 ms
41,212 KB
testcase_33 AC 138 ms
41,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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(n>i){
			now_wide += w[i];
			if(now_wide > l){
				break;
			}
			i++;
		}
		System.out.println(i);
	}
}
0