結果

問題 No.45 回転寿司
ユーザー rn4rurn4ru
提出日時 2016-04-14 06:51:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 3,644 ms
コンパイル使用メモリ 71,460 KB
実行使用メモリ 56,884 KB
最終ジャッジ日時 2023-08-27 14:46:47
合計ジャッジ時間 9,934 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
54,464 KB
testcase_01 AC 188 ms
56,400 KB
testcase_02 AC 196 ms
56,724 KB
testcase_03 AC 196 ms
56,884 KB
testcase_04 AC 188 ms
55,896 KB
testcase_05 AC 136 ms
55,724 KB
testcase_06 AC 192 ms
53,728 KB
testcase_07 AC 198 ms
56,736 KB
testcase_08 AC 152 ms
55,884 KB
testcase_09 AC 195 ms
56,448 KB
testcase_10 AC 154 ms
55,972 KB
testcase_11 AC 144 ms
55,920 KB
testcase_12 AC 201 ms
56,420 KB
testcase_13 AC 137 ms
55,744 KB
testcase_14 AC 132 ms
56,144 KB
testcase_15 AC 189 ms
56,652 KB
testcase_16 AC 154 ms
56,036 KB
testcase_17 AC 174 ms
55,916 KB
testcase_18 AC 157 ms
55,712 KB
testcase_19 AC 197 ms
56,044 KB
testcase_20 AC 132 ms
56,084 KB
testcase_21 AC 134 ms
56,096 KB
testcase_22 AC 125 ms
55,976 KB
testcase_23 AC 125 ms
55,528 KB
testcase_24 AC 126 ms
55,724 KB
testcase_25 AC 125 ms
56,384 KB
testcase_26 AC 184 ms
56,284 KB
testcase_27 AC 189 ms
56,548 KB
testcase_28 AC 185 ms
56,544 KB
testcase_29 AC 201 ms
56,556 KB
testcase_30 AC 200 ms
56,516 KB
testcase_31 AC 126 ms
55,728 KB
testcase_32 AC 126 ms
55,448 KB
testcase_33 AC 201 ms
56,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] V = new int[N + 1];

		for (int i = 1; i <= N; i++) {
			V[i] = scanner.nextInt();
		}

		int[] dp = new int[N + 1];
		dp[1] = V[1];
		for (int i = 2; i <= N; i++) {
			int max = dp[i - 1];
			for (int j = 0; j < i - 1; j++) {
				max = Math.max(max, dp[j] + V[i]);
			}
			dp[i] = max;
		}

		System.out.println(dp[N]);
	}

}
0