結果

問題 No.45 回転寿司
ユーザー ぴろずぴろず
提出日時 2014-12-15 15:58:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 470 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 72,016 KB
実行使用メモリ 56,696 KB
最終ジャッジ日時 2023-08-27 13:53:45
合計ジャッジ時間 8,332 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
56,120 KB
testcase_01 AC 165 ms
55,848 KB
testcase_02 AC 160 ms
56,140 KB
testcase_03 AC 172 ms
56,092 KB
testcase_04 AC 167 ms
55,988 KB
testcase_05 AC 125 ms
55,540 KB
testcase_06 AC 163 ms
56,696 KB
testcase_07 AC 165 ms
55,740 KB
testcase_08 AC 147 ms
55,868 KB
testcase_09 AC 162 ms
56,492 KB
testcase_10 AC 159 ms
56,004 KB
testcase_11 AC 132 ms
55,560 KB
testcase_12 AC 168 ms
56,020 KB
testcase_13 AC 125 ms
55,592 KB
testcase_14 AC 123 ms
55,792 KB
testcase_15 AC 161 ms
55,812 KB
testcase_16 AC 137 ms
56,208 KB
testcase_17 AC 159 ms
56,164 KB
testcase_18 AC 143 ms
55,780 KB
testcase_19 AC 167 ms
56,096 KB
testcase_20 AC 127 ms
55,544 KB
testcase_21 AC 126 ms
55,516 KB
testcase_22 AC 115 ms
55,552 KB
testcase_23 AC 117 ms
55,740 KB
testcase_24 AC 118 ms
55,564 KB
testcase_25 AC 119 ms
55,552 KB
testcase_26 AC 162 ms
55,792 KB
testcase_27 AC 167 ms
56,184 KB
testcase_28 AC 166 ms
55,712 KB
testcase_29 AC 167 ms
56,248 KB
testcase_30 AC 174 ms
56,040 KB
testcase_31 AC 118 ms
55,708 KB
testcase_32 AC 117 ms
56,244 KB
testcase_33 AC 179 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no045;

import java.util.Scanner;

public class Main {

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

}
0