結果

問題 No.5 数字のブロック
ユーザー 8130Tsk8130Tsk
提出日時 2015-07-26 22:21:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 542 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 75,788 KB
実行使用メモリ 47,876 KB
最終ジャッジ日時 2024-04-29 06:21:49
合計ジャッジ時間 11,091 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
40,964 KB
testcase_01 AC 129 ms
41,436 KB
testcase_02 AC 136 ms
41,132 KB
testcase_03 AC 249 ms
46,516 KB
testcase_04 AC 219 ms
45,716 KB
testcase_05 AC 260 ms
47,280 KB
testcase_06 AC 237 ms
46,528 KB
testcase_07 AC 231 ms
45,536 KB
testcase_08 AC 247 ms
46,416 KB
testcase_09 AC 207 ms
43,700 KB
testcase_10 AC 251 ms
47,588 KB
testcase_11 AC 210 ms
46,044 KB
testcase_12 AC 243 ms
46,460 KB
testcase_13 AC 252 ms
47,220 KB
testcase_14 AC 144 ms
41,552 KB
testcase_15 AC 155 ms
41,616 KB
testcase_16 AC 259 ms
47,308 KB
testcase_17 AC 265 ms
47,592 KB
testcase_18 AC 264 ms
47,876 KB
testcase_19 AC 274 ms
47,712 KB
testcase_20 AC 129 ms
41,400 KB
testcase_21 AC 126 ms
41,684 KB
testcase_22 AC 131 ms
41,600 KB
testcase_23 AC 128 ms
41,268 KB
testcase_24 AC 164 ms
41,780 KB
testcase_25 AC 180 ms
41,908 KB
testcase_26 AC 128 ms
41,032 KB
testcase_27 AC 126 ms
41,468 KB
testcase_28 AC 129 ms
41,708 KB
testcase_29 AC 224 ms
45,620 KB
testcase_30 AC 208 ms
43,504 KB
testcase_31 AC 129 ms
41,500 KB
testcase_32 AC 133 ms
41,608 KB
testcase_33 AC 135 ms
41,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No5 {

	public void run(){
		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 sum = 0;
		int count = 0;
		for(int i=0; i<N ;i++){
			sum+=w[i];
			if(sum>L)
				break;
			count++;
		}
		
		System.out.println(count);
		
		
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new No5().run();
	}

}
0