結果

問題 No.2093 Shio Ramen
ユーザー ks2mks2m
提出日時 2022-10-07 21:28:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 749 bytes
コンパイル時間 3,890 ms
コンパイル使用メモリ 73,336 KB
実行使用メモリ 52,240 KB
最終ジャッジ日時 2023-09-03 00:14:12
合計ジャッジ時間 6,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
49,348 KB
testcase_01 AC 37 ms
49,108 KB
testcase_02 AC 37 ms
49,564 KB
testcase_03 AC 37 ms
49,116 KB
testcase_04 AC 37 ms
49,408 KB
testcase_05 AC 38 ms
49,228 KB
testcase_06 AC 38 ms
49,520 KB
testcase_07 AC 37 ms
49,444 KB
testcase_08 AC 38 ms
49,344 KB
testcase_09 AC 46 ms
49,616 KB
testcase_10 AC 68 ms
52,084 KB
testcase_11 AC 40 ms
47,228 KB
testcase_12 AC 53 ms
51,556 KB
testcase_13 AC 51 ms
50,720 KB
testcase_14 AC 59 ms
50,492 KB
testcase_15 AC 67 ms
51,832 KB
testcase_16 AC 48 ms
49,316 KB
testcase_17 AC 57 ms
50,468 KB
testcase_18 AC 67 ms
52,088 KB
testcase_19 AC 68 ms
52,188 KB
testcase_20 AC 69 ms
50,852 KB
testcase_21 AC 66 ms
51,832 KB
testcase_22 AC 71 ms
50,908 KB
testcase_23 AC 72 ms
51,644 KB
testcase_24 AC 70 ms
51,848 KB
testcase_25 AC 70 ms
51,856 KB
testcase_26 AC 72 ms
52,240 KB
testcase_27 AC 76 ms
51,868 KB
testcase_28 AC 70 ms
51,852 KB
testcase_29 AC 70 ms
51,840 KB
testcase_30 AC 67 ms
51,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int[] s = new int[n];
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			s[i] = Integer.parseInt(sa[0]);
			a[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		int[] dp = new int[m + 1];
		for (int i = 0; i < n; i++) {
			for (int j = m - s[i]; j >= 0; j--) {
				int nj = j + s[i];
				dp[nj] = Math.max(dp[nj], dp[j] + a[i]);
			}
		}
		System.out.println(dp[m]);
	}
}
0