結果

問題 No.45 回転寿司
ユーザー GrenacheGrenache
提出日時 2015-07-01 10:39:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 5,006 ms
コンパイル使用メモリ 72,960 KB
実行使用メモリ 56,772 KB
最終ジャッジ日時 2023-08-27 14:10:20
合計ジャッジ時間 11,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
56,268 KB
testcase_01 AC 156 ms
55,792 KB
testcase_02 AC 165 ms
56,452 KB
testcase_03 AC 166 ms
56,072 KB
testcase_04 AC 160 ms
56,108 KB
testcase_05 AC 127 ms
56,232 KB
testcase_06 AC 157 ms
56,376 KB
testcase_07 AC 157 ms
56,284 KB
testcase_08 AC 131 ms
56,184 KB
testcase_09 AC 161 ms
56,440 KB
testcase_10 AC 163 ms
56,044 KB
testcase_11 AC 139 ms
55,580 KB
testcase_12 AC 166 ms
56,364 KB
testcase_13 AC 136 ms
55,460 KB
testcase_14 AC 123 ms
55,740 KB
testcase_15 AC 162 ms
56,020 KB
testcase_16 AC 140 ms
56,188 KB
testcase_17 AC 144 ms
55,784 KB
testcase_18 AC 149 ms
55,812 KB
testcase_19 AC 165 ms
56,248 KB
testcase_20 AC 115 ms
55,576 KB
testcase_21 AC 121 ms
56,044 KB
testcase_22 AC 111 ms
55,848 KB
testcase_23 AC 110 ms
55,464 KB
testcase_24 AC 115 ms
55,880 KB
testcase_25 AC 117 ms
55,980 KB
testcase_26 AC 164 ms
56,168 KB
testcase_27 AC 156 ms
55,864 KB
testcase_28 AC 163 ms
56,060 KB
testcase_29 AC 162 ms
56,184 KB
testcase_30 AC 162 ms
56,772 KB
testcase_31 AC 113 ms
55,884 KB
testcase_32 AC 117 ms
55,840 KB
testcase_33 AC 168 ms
56,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder45 {

    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];
        int max = 0;
        for (int i = 0; i < n; i++) {
        	dp[i] = v[i];
        	
        	for (int j = Math.max(0, i - 3); j < i - 1; j++) {
        		dp[i] = Math.max(dp[i], dp[j] + v[i]);
        	}
        	max = Math.max(max, dp[i]);
        }

        System.out.println(max);
        
        sc.close();
    }
}
0