結果

問題 No.45 回転寿司
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-12-06 05:21:48
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 4,665 ms
コンパイル使用メモリ 71,796 KB
実行使用メモリ 57,012 KB
最終ジャッジ日時 2023-08-18 18:20:27
合計ジャッジ時間 10,798 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
56,072 KB
testcase_01 AC 176 ms
56,652 KB
testcase_02 WA -
testcase_03 AC 167 ms
55,740 KB
testcase_04 AC 174 ms
56,232 KB
testcase_05 AC 130 ms
55,720 KB
testcase_06 AC 164 ms
56,248 KB
testcase_07 AC 177 ms
55,952 KB
testcase_08 WA -
testcase_09 AC 178 ms
56,260 KB
testcase_10 AC 170 ms
56,028 KB
testcase_11 WA -
testcase_12 AC 180 ms
56,264 KB
testcase_13 AC 131 ms
55,528 KB
testcase_14 AC 129 ms
55,844 KB
testcase_15 AC 171 ms
56,024 KB
testcase_16 WA -
testcase_17 AC 169 ms
56,404 KB
testcase_18 AC 159 ms
55,936 KB
testcase_19 WA -
testcase_20 AC 127 ms
55,516 KB
testcase_21 AC 129 ms
55,388 KB
testcase_22 AC 121 ms
55,820 KB
testcase_23 WA -
testcase_24 AC 121 ms
56,508 KB
testcase_25 RE -
testcase_26 AC 159 ms
56,324 KB
testcase_27 WA -
testcase_28 AC 176 ms
55,568 KB
testcase_29 AC 165 ms
56,172 KB
testcase_30 AC 182 ms
56,276 KB
testcase_31 AC 121 ms
55,948 KB
testcase_32 AC 121 ms
55,704 KB
testcase_33 AC 182 ms
56,860 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 [] V = new int [N];
        for(int i=0; i<N; i++){
            V[i]=sc.nextInt();
        }
        int [] dp = new int [N];
        dp[0]=V[0];
        dp[1]=V[1];
        for(int i=2; i<N; i++){
            dp[i]=Math.max(dp[i-1],dp[i-2]+V[i]);
        }
        System.out.println(Math.max(dp[N-1],dp[N-2]));
    }
}
0