結果

問題 No.2317 Expression Menu
ユーザー ks2mks2m
提出日時 2023-05-26 21:33:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 318 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 4,306 ms
コンパイル使用メモリ 73,992 KB
実行使用メモリ 64,160 KB
最終ジャッジ日時 2023-08-26 10:35:19
合計ジャッジ時間 13,729 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
49,224 KB
testcase_01 AC 41 ms
49,308 KB
testcase_02 AC 98 ms
57,568 KB
testcase_03 AC 279 ms
63,432 KB
testcase_04 AC 257 ms
63,308 KB
testcase_05 AC 249 ms
63,168 KB
testcase_06 AC 246 ms
63,128 KB
testcase_07 AC 258 ms
63,344 KB
testcase_08 AC 255 ms
63,380 KB
testcase_09 AC 253 ms
63,476 KB
testcase_10 AC 264 ms
63,176 KB
testcase_11 AC 258 ms
63,216 KB
testcase_12 AC 257 ms
63,580 KB
testcase_13 AC 264 ms
61,668 KB
testcase_14 AC 253 ms
61,360 KB
testcase_15 AC 257 ms
63,336 KB
testcase_16 AC 281 ms
64,160 KB
testcase_17 AC 265 ms
63,332 KB
testcase_18 AC 263 ms
63,136 KB
testcase_19 AC 260 ms
63,540 KB
testcase_20 AC 252 ms
63,872 KB
testcase_21 AC 268 ms
63,432 KB
testcase_22 AC 251 ms
63,160 KB
testcase_23 AC 290 ms
63,392 KB
testcase_24 AC 308 ms
63,448 KB
testcase_25 AC 302 ms
63,380 KB
testcase_26 AC 302 ms
63,736 KB
testcase_27 AC 298 ms
63,004 KB
testcase_28 AC 296 ms
63,528 KB
testcase_29 AC 300 ms
63,460 KB
testcase_30 AC 304 ms
63,884 KB
testcase_31 AC 304 ms
63,436 KB
testcase_32 AC 295 ms
63,424 KB
testcase_33 AC 39 ms
49,300 KB
testcase_34 AC 40 ms
49,196 KB
testcase_35 AC 53 ms
50,388 KB
testcase_36 AC 38 ms
49,356 KB
testcase_37 AC 40 ms
49,236 KB
testcase_38 AC 310 ms
63,224 KB
testcase_39 AC 318 ms
62,824 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 x = Integer.parseInt(sa[1]);
		int y = Integer.parseInt(sa[2]);
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]);
			b[i] = Integer.parseInt(sa[1]);
			c[i] = Integer.parseInt(sa[2]);
		}
		br.close();

		long[][] dp = new long[x + 1][y + 1];
		for (int i = 0; i < n; i++) {
			long[][] wk = new long[x + 1][y + 1];
			for (int j = 0; j <= x; j++) {
				for (int j2 = 0; j2 <= y; j2++) {
					wk[j][j2] = Math.max(wk[j][j2], dp[j][j2]);
					int nj = j + a[i];
					int nj2 = j2 + b[i];
					if (nj <= x && nj2 <= y) {
						wk[nj][nj2] = Math.max(wk[nj][nj2], dp[j][j2] + c[i]);
					}
				}
			}
			dp = wk;
		}
		long ans = 0;
		for (int j = 0; j <= x; j++) {
			for (int j2 = 0; j2 <= y; j2++) {
				ans = Math.max(ans, dp[j][j2]);
			}
		}
		System.out.println(ans);
	}
}
0