結果

問題 No.45 回転寿司
ユーザー shinwisteriashinwisteria
提出日時 2017-03-21 19:49:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 3,636 ms
コンパイル使用メモリ 73,968 KB
実行使用メモリ 58,148 KB
最終ジャッジ日時 2023-09-18 15:35:23
合計ジャッジ時間 10,678 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 187 ms
56,484 KB
testcase_02 AC 192 ms
57,016 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 138 ms
55,792 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 156 ms
56,028 KB
testcase_09 AC 187 ms
55,724 KB
testcase_10 WA -
testcase_11 AC 147 ms
55,780 KB
testcase_12 AC 189 ms
56,400 KB
testcase_13 WA -
testcase_14 AC 136 ms
55,664 KB
testcase_15 AC 163 ms
56,100 KB
testcase_16 AC 154 ms
56,232 KB
testcase_17 AC 174 ms
56,252 KB
testcase_18 WA -
testcase_19 AC 191 ms
55,836 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 127 ms
55,960 KB
testcase_23 AC 127 ms
55,784 KB
testcase_24 AC 129 ms
55,860 KB
testcase_25 AC 127 ms
55,904 KB
testcase_26 AC 183 ms
56,204 KB
testcase_27 AC 179 ms
57,672 KB
testcase_28 WA -
testcase_29 AC 187 ms
55,792 KB
testcase_30 AC 191 ms
56,080 KB
testcase_31 AC 127 ms
55,860 KB
testcase_32 AC 129 ms
55,864 KB
testcase_33 AC 188 ms
56,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class Kaitenzushi { 

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		ArrayList<Integer> V = new ArrayList<>();
		for(int i = 0;i < N;i++){
			V.add(s.nextInt());	
		}
		int MAX = 0;
		s.close();
		if(N == 1){
			MAX = V.get(0);
		}else {
			int D2 = Integer.max(V.get(0), V.get(1)),D1 = Integer.min(V.get(0), V.get(1));
			if(N == 2){
				MAX = Integer.max(D1, D2);
			}else{
				for(int i = 2;i<N;i++){
					MAX = Integer.max(D1+V.get(i), D2);
					D1 = D2;
					D2 = MAX;
				}
			}
		}
		System.out.println(MAX);
	}
}
0