結果

問題 No.45 回転寿司
ユーザー htensaihtensai
提出日時 2020-05-07 13:16:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 353 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 71,480 KB
実行使用メモリ 57,044 KB
最終ジャッジ日時 2023-09-16 07:51:42
合計ジャッジ時間 9,881 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
56,248 KB
testcase_01 AC 179 ms
55,980 KB
testcase_02 AC 181 ms
57,044 KB
testcase_03 AC 171 ms
56,164 KB
testcase_04 AC 165 ms
55,948 KB
testcase_05 AC 133 ms
55,912 KB
testcase_06 AC 179 ms
56,316 KB
testcase_07 AC 181 ms
56,396 KB
testcase_08 AC 156 ms
56,156 KB
testcase_09 AC 180 ms
55,976 KB
testcase_10 AC 165 ms
56,184 KB
testcase_11 AC 147 ms
55,800 KB
testcase_12 AC 185 ms
56,416 KB
testcase_13 AC 138 ms
56,056 KB
testcase_14 AC 134 ms
56,212 KB
testcase_15 AC 155 ms
55,904 KB
testcase_16 AC 156 ms
56,144 KB
testcase_17 AC 177 ms
56,188 KB
testcase_18 AC 152 ms
55,952 KB
testcase_19 AC 182 ms
56,164 KB
testcase_20 AC 131 ms
55,752 KB
testcase_21 AC 131 ms
55,868 KB
testcase_22 AC 125 ms
55,696 KB
testcase_23 AC 123 ms
55,760 KB
testcase_24 AC 124 ms
55,604 KB
testcase_25 AC 124 ms
55,788 KB
testcase_26 AC 164 ms
56,224 KB
testcase_27 AC 179 ms
56,020 KB
testcase_28 AC 168 ms
55,904 KB
testcase_29 AC 177 ms
56,220 KB
testcase_30 AC 170 ms
56,112 KB
testcase_31 AC 123 ms
55,920 KB
testcase_32 AC 123 ms
55,896 KB
testcase_33 AC 184 ms
56,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] dp = new int[n + 3];
		for (int i = 3; i < n + 3; i++) {
		    int x = sc.nextInt();
		    dp[i] = Math.max(dp[i - 2], dp[i - 3]) + x;
		}
		System.out.println(Math.max(dp[n + 2], dp[n + 1]));
	}
}
0