結果

問題 No.5 数字のブロック
ユーザー rabirabi
提出日時 2019-06-24 14:48:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 883 bytes
コンパイル時間 3,794 ms
コンパイル使用メモリ 74,052 KB
実行使用メモリ 53,204 KB
最終ジャッジ日時 2023-09-02 08:44:11
合計ジャッジ時間 8,276 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,384 KB
testcase_01 AC 46 ms
49,596 KB
testcase_02 AC 46 ms
49,492 KB
testcase_03 AC 90 ms
53,204 KB
testcase_04 AC 65 ms
51,460 KB
testcase_05 AC 93 ms
52,688 KB
testcase_06 AC 79 ms
52,516 KB
testcase_07 AC 69 ms
51,320 KB
testcase_08 AC 74 ms
52,064 KB
testcase_09 AC 60 ms
51,452 KB
testcase_10 AC 92 ms
52,840 KB
testcase_11 AC 66 ms
51,552 KB
testcase_12 AC 91 ms
52,440 KB
testcase_13 AC 76 ms
52,540 KB
testcase_14 AC 46 ms
49,376 KB
testcase_15 AC 47 ms
49,388 KB
testcase_16 AC 83 ms
52,908 KB
testcase_17 AC 94 ms
52,964 KB
testcase_18 AC 95 ms
52,896 KB
testcase_19 AC 94 ms
52,224 KB
testcase_20 AC 45 ms
49,576 KB
testcase_21 AC 44 ms
49,280 KB
testcase_22 AC 45 ms
49,364 KB
testcase_23 AC 45 ms
49,380 KB
testcase_24 AC 49 ms
49,920 KB
testcase_25 AC 49 ms
49,292 KB
testcase_26 AC 45 ms
49,388 KB
testcase_27 AC 45 ms
49,852 KB
testcase_28 AC 44 ms
49,464 KB
testcase_29 AC 67 ms
51,540 KB
testcase_30 AC 59 ms
51,408 KB
testcase_31 AC 45 ms
49,464 KB
testcase_32 AC 45 ms
49,592 KB
testcase_33 AC 45 ms
49,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Tester2 {
	public static void main(String[] args){
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			int l = Integer.parseInt(br.readLine());
			int n = Integer.parseInt(br.readLine());
			String[] ary = br.readLine().split(" ");
			int[] b = chgInt(ary);

			int num=0,cnt=0;
			for(int i=0; i<b.length; i++) {
				num += b[i];
				if(num<=l) {
					cnt++;
				}else {
					break;
				}
			}
			System.out.println(cnt);

		}catch(IOException e) {
			e.printStackTrace();
		}
	}
	static int[] sort(int[] ary) {
		Arrays.sort(ary);
		return ary;
	}
	static int[] chgInt(String[] ary) {
		int[] a = new int[ary.length];
		for(int i=0; i<ary.length; i++) {
			a[i] = Integer.parseInt(ary[i]);
		}
		return sort(a);
	}

}
0