結果

問題 No.5 数字のブロック
ユーザー kanra661kanra661
提出日時 2014-12-16 16:29:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 256 ms / 5,000 ms
コード長 433 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 72,004 KB
実行使用メモリ 60,704 KB
最終ジャッジ日時 2023-08-11 07:52:30
合計ジャッジ時間 9,416 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,976 KB
testcase_01 AC 119 ms
55,660 KB
testcase_02 AC 122 ms
56,180 KB
testcase_03 AC 224 ms
59,740 KB
testcase_04 AC 209 ms
59,828 KB
testcase_05 AC 233 ms
59,868 KB
testcase_06 AC 202 ms
59,920 KB
testcase_07 AC 210 ms
58,900 KB
testcase_08 AC 214 ms
60,524 KB
testcase_09 AC 191 ms
56,272 KB
testcase_10 AC 237 ms
59,336 KB
testcase_11 AC 206 ms
59,360 KB
testcase_12 AC 227 ms
59,768 KB
testcase_13 AC 237 ms
59,992 KB
testcase_14 AC 132 ms
55,764 KB
testcase_15 AC 143 ms
56,344 KB
testcase_16 AC 241 ms
60,584 KB
testcase_17 AC 245 ms
60,212 KB
testcase_18 AC 246 ms
60,248 KB
testcase_19 AC 256 ms
60,704 KB
testcase_20 AC 124 ms
55,744 KB
testcase_21 AC 121 ms
55,320 KB
testcase_22 AC 120 ms
56,228 KB
testcase_23 AC 118 ms
56,044 KB
testcase_24 AC 154 ms
56,152 KB
testcase_25 AC 175 ms
56,372 KB
testcase_26 AC 121 ms
55,828 KB
testcase_27 AC 124 ms
56,008 KB
testcase_28 AC 120 ms
55,972 KB
testcase_29 AC 217 ms
59,296 KB
testcase_30 AC 192 ms
58,440 KB
testcase_31 AC 120 ms
55,300 KB
testcase_32 AC 123 ms
56,132 KB
testcase_33 AC 126 ms
55,924 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