結果

問題 No.2093 Shio Ramen
ユーザー viral8viral8
提出日時 2022-10-07 22:37:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 2,165 ms
コンパイル使用メモリ 74,072 KB
実行使用メモリ 59,540 KB
最終ジャッジ日時 2023-09-03 14:01:23
合計ジャッジ時間 9,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,004 KB
testcase_01 AC 123 ms
56,124 KB
testcase_02 AC 125 ms
56,068 KB
testcase_03 AC 124 ms
55,976 KB
testcase_04 AC 120 ms
55,708 KB
testcase_05 AC 122 ms
55,632 KB
testcase_06 AC 124 ms
55,900 KB
testcase_07 AC 124 ms
55,964 KB
testcase_08 AC 120 ms
55,632 KB
testcase_09 AC 189 ms
56,524 KB
testcase_10 AC 219 ms
58,948 KB
testcase_11 AC 136 ms
56,144 KB
testcase_12 AC 198 ms
58,624 KB
testcase_13 AC 196 ms
58,068 KB
testcase_14 AC 199 ms
58,600 KB
testcase_15 AC 216 ms
59,204 KB
testcase_16 AC 183 ms
58,284 KB
testcase_17 AC 204 ms
58,884 KB
testcase_18 AC 225 ms
59,540 KB
testcase_19 AC 218 ms
58,988 KB
testcase_20 AC 217 ms
59,236 KB
testcase_21 AC 215 ms
59,328 KB
testcase_22 AC 212 ms
59,532 KB
testcase_23 AC 225 ms
58,876 KB
testcase_24 AC 221 ms
59,200 KB
testcase_25 AC 222 ms
58,996 KB
testcase_26 AC 224 ms
59,448 KB
testcase_27 AC 224 ms
58,952 KB
testcase_28 AC 226 ms
59,228 KB
testcase_29 AC 232 ms
59,100 KB
testcase_30 AC 219 ms
59,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int I = sc.nextInt();
		int[][] sa = new int[N+1][2];
		for(int i=1;i<=N;i++){
			sa[i][0] = sc.nextInt();
			sa[i][1] = sc.nextInt();
		}
		int[][] dp = new int[N+1][I+1];
		for(int i=1;i<=N;i++){
			for(int j=0;j<=I;j++){
				dp[i][j] = Math.max(dp[i][j],dp[i-1][j]);
				if(j+sa[i][0]<=I)
					dp[i][j+sa[i][0]] = dp[i-1][j]+sa[i][1];
			}
		}
		System.out.println(dp[N][I]);
	}
}
0