結果

問題 No.45 回転寿司
ユーザー jimanojimano
提出日時 2018-02-04 21:11:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 796 bytes
コンパイル時間 6,470 ms
コンパイル使用メモリ 73,716 KB
実行使用メモリ 49,600 KB
最終ジャッジ日時 2023-08-27 16:18:58
合計ジャッジ時間 8,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
49,312 KB
testcase_01 AC 51 ms
49,432 KB
testcase_02 AC 53 ms
49,236 KB
testcase_03 AC 53 ms
49,160 KB
testcase_04 AC 50 ms
47,364 KB
testcase_05 AC 47 ms
49,264 KB
testcase_06 AC 49 ms
49,368 KB
testcase_07 AC 52 ms
49,284 KB
testcase_08 AC 48 ms
49,340 KB
testcase_09 AC 53 ms
49,240 KB
testcase_10 AC 48 ms
49,308 KB
testcase_11 AC 47 ms
49,472 KB
testcase_12 AC 52 ms
49,372 KB
testcase_13 AC 47 ms
49,400 KB
testcase_14 AC 47 ms
49,256 KB
testcase_15 AC 50 ms
49,152 KB
testcase_16 AC 48 ms
49,368 KB
testcase_17 AC 49 ms
49,308 KB
testcase_18 AC 49 ms
49,256 KB
testcase_19 AC 52 ms
49,428 KB
testcase_20 AC 47 ms
49,560 KB
testcase_21 AC 47 ms
49,600 KB
testcase_22 AC 46 ms
49,264 KB
testcase_23 AC 46 ms
49,312 KB
testcase_24 AC 46 ms
49,292 KB
testcase_25 AC 46 ms
49,248 KB
testcase_26 AC 48 ms
49,436 KB
testcase_27 AC 52 ms
49,196 KB
testcase_28 AC 50 ms
49,248 KB
testcase_29 AC 51 ms
49,524 KB
testcase_30 AC 51 ms
47,268 KB
testcase_31 AC 45 ms
49,432 KB
testcase_32 AC 45 ms
49,296 KB
testcase_33 AC 53 ms
49,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No0045 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int cntDish = Integer.parseInt(br.readLine());
			String[] str = br.readLine().split(" ");
			int[] v = new int[cntDish];
			int[] max = new int[cntDish];

			for (int i = 0; i < cntDish; i++) {
				v[i] = Integer.parseInt(str[i]);
			}

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

			System.out.println(max[cntDish - 1]);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0