結果

問題 No.5 数字のブロック
ユーザー chamc1984chamc1984
提出日時 2017-12-27 00:30:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 1,066 bytes
コンパイル時間 3,824 ms
コンパイル使用メモリ 73,412 KB
実行使用メモリ 53,460 KB
最終ジャッジ日時 2023-08-11 18:00:40
合計ジャッジ時間 7,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,480 KB
testcase_01 AC 45 ms
47,884 KB
testcase_02 AC 46 ms
49,424 KB
testcase_03 AC 82 ms
51,812 KB
testcase_04 AC 77 ms
51,432 KB
testcase_05 AC 97 ms
52,936 KB
testcase_06 AC 85 ms
52,576 KB
testcase_07 AC 76 ms
52,152 KB
testcase_08 AC 84 ms
52,712 KB
testcase_09 AC 62 ms
50,868 KB
testcase_10 AC 95 ms
52,648 KB
testcase_11 AC 74 ms
51,840 KB
testcase_12 AC 88 ms
52,780 KB
testcase_13 AC 89 ms
52,420 KB
testcase_14 AC 46 ms
49,484 KB
testcase_15 AC 47 ms
49,432 KB
testcase_16 AC 91 ms
52,444 KB
testcase_17 AC 104 ms
52,616 KB
testcase_18 AC 103 ms
52,668 KB
testcase_19 AC 110 ms
53,460 KB
testcase_20 AC 45 ms
49,284 KB
testcase_21 AC 45 ms
49,740 KB
testcase_22 AC 44 ms
49,280 KB
testcase_23 AC 46 ms
49,276 KB
testcase_24 AC 49 ms
49,616 KB
testcase_25 AC 51 ms
49,744 KB
testcase_26 AC 44 ms
49,556 KB
testcase_27 AC 45 ms
49,412 KB
testcase_28 AC 45 ms
49,268 KB
testcase_29 AC 75 ms
51,748 KB
testcase_30 AC 67 ms
51,404 KB
testcase_31 AC 47 ms
49,548 KB
testcase_32 AC 47 ms
49,460 KB
testcase_33 AC 43 ms
49,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class YukiCoderNo5 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		// Read Input
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		try{
			// Read 1st line
			int L = Integer.parseInt(br.readLine());
			
			// Read 2nd line
			int N = Integer.parseInt(br.readLine());
			
			// Read 3rd line to ArrayList
			String s[] = br.readLine().split(" ");
			ArrayList<Integer> list = new ArrayList<Integer>();
			for( int i=0; i<N; i++ ) {
				list.add(Integer.parseInt(s[i]));
			}
			Collections.sort(list);
			
			int sum = 0;
			int cnt = 0;
			for( int i=0; i<list.size(); i++ ) {
				sum+=list.get(i);
//				System.out.println("debug: " + sum);
				if(L < sum){
					break;
				}
				cnt++;
			}
			
			// Output RESULT
			System.out.println(cnt);
			
		} catch(Exception e) {
			System.out.println("error!");
			return;			
		}
		
		return;
	}

}
0