結果

問題 No.45 回転寿司
ユーザー wildwild
提出日時 2017-05-04 21:25:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 172 ms / 5,000 ms
コード長 593 bytes
コンパイル時間 3,700 ms
コンパイル使用メモリ 72,864 KB
実行使用メモリ 56,688 KB
最終ジャッジ日時 2023-08-27 15:27:58
合計ジャッジ時間 10,126 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 153 ms
55,896 KB
testcase_01 AC 165 ms
56,256 KB
testcase_02 AC 163 ms
56,688 KB
testcase_03 AC 151 ms
55,784 KB
testcase_04 AC 160 ms
56,004 KB
testcase_05 AC 120 ms
56,296 KB
testcase_06 AC 157 ms
56,140 KB
testcase_07 AC 157 ms
56,204 KB
testcase_08 AC 137 ms
56,044 KB
testcase_09 AC 165 ms
56,048 KB
testcase_10 AC 150 ms
56,432 KB
testcase_11 AC 126 ms
56,096 KB
testcase_12 AC 160 ms
56,140 KB
testcase_13 AC 114 ms
55,792 KB
testcase_14 AC 117 ms
56,068 KB
testcase_15 AC 155 ms
56,288 KB
testcase_16 AC 131 ms
56,016 KB
testcase_17 AC 161 ms
56,588 KB
testcase_18 AC 141 ms
56,452 KB
testcase_19 AC 172 ms
56,064 KB
testcase_20 AC 119 ms
55,640 KB
testcase_21 AC 120 ms
56,048 KB
testcase_22 AC 108 ms
56,096 KB
testcase_23 AC 112 ms
56,012 KB
testcase_24 AC 112 ms
55,828 KB
testcase_25 AC 115 ms
55,756 KB
testcase_26 AC 156 ms
56,668 KB
testcase_27 AC 154 ms
56,424 KB
testcase_28 AC 154 ms
56,032 KB
testcase_29 AC 144 ms
56,496 KB
testcase_30 AC 158 ms
56,336 KB
testcase_31 AC 110 ms
55,844 KB
testcase_32 AC 103 ms
55,808 KB
testcase_33 AC 158 ms
56,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

/**
 * Created by whiled on 17/05/04.
 */
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] v = new int[N];
        for (int i=0; i<N; i++) v[i] = scan.nextInt();

        int[] res = new int[N+1];

        res[0] = 0;
        res[1] = v[0];
        if (res.length > 2) res[2] = Math.max(v[0], v[1]);
        for (int i=2; i<res.length-1; i++){
            res[i+1] = Math.max(res[i], res[i-1] + v[i]);
        }

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


}
0