結果

問題 No.45 回転寿司
ユーザー nCk_cvnCk_cv
提出日時 2016-02-17 16:42:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 54,656 KB
最終ジャッジ日時 2024-05-03 11:46:14
合計ジャッジ時間 8,508 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
53,960 KB
testcase_01 AC 167 ms
54,468 KB
testcase_02 AC 173 ms
54,420 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 149 ms
54,292 KB
testcase_06 AC 175 ms
54,208 KB
testcase_07 WA -
testcase_08 AC 153 ms
54,448 KB
testcase_09 AC 191 ms
54,444 KB
testcase_10 AC 190 ms
54,112 KB
testcase_11 AC 140 ms
53,888 KB
testcase_12 WA -
testcase_13 AC 128 ms
54,056 KB
testcase_14 WA -
testcase_15 AC 165 ms
54,076 KB
testcase_16 AC 148 ms
54,556 KB
testcase_17 AC 155 ms
54,332 KB
testcase_18 AC 140 ms
54,184 KB
testcase_19 AC 162 ms
54,416 KB
testcase_20 AC 122 ms
54,156 KB
testcase_21 AC 135 ms
54,264 KB
testcase_22 AC 118 ms
54,124 KB
testcase_23 AC 116 ms
53,956 KB
testcase_24 AC 124 ms
53,980 KB
testcase_25 AC 121 ms
54,504 KB
testcase_26 AC 152 ms
54,176 KB
testcase_27 AC 164 ms
54,264 KB
testcase_28 AC 159 ms
54,344 KB
testcase_29 WA -
testcase_30 AC 156 ms
54,156 KB
testcase_31 AC 116 ms
53,948 KB
testcase_32 WA -
testcase_33 AC 167 ms
54,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.awt.geom.*;
import java.io.*;
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+2];
		for(int i = 0; i < N; i++) {
			dp[i+1] = Math.max(dp[i], dp[i+1]);
			dp[i+2] = Math.max(dp[i] + V[i], dp[i+2]);
		}
		System.out.println((dp[N+1]));
 	}
}
0