結果

問題 No.45 回転寿司
ユーザー uafr_csuafr_cs
提出日時 2015-06-03 17:18:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 573 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 56,412 KB
最終ジャッジ日時 2023-08-27 14:02:06
合計ジャッジ時間 8,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
55,520 KB
testcase_01 AC 188 ms
55,948 KB
testcase_02 AC 188 ms
56,264 KB
testcase_03 AC 188 ms
55,616 KB
testcase_04 AC 184 ms
56,244 KB
testcase_05 AC 138 ms
55,592 KB
testcase_06 AC 184 ms
55,888 KB
testcase_07 AC 187 ms
55,924 KB
testcase_08 AC 154 ms
55,888 KB
testcase_09 AC 185 ms
56,256 KB
testcase_10 AC 182 ms
55,996 KB
testcase_11 AC 145 ms
55,520 KB
testcase_12 AC 186 ms
56,116 KB
testcase_13 AC 134 ms
56,040 KB
testcase_14 AC 134 ms
56,156 KB
testcase_15 AC 153 ms
55,896 KB
testcase_16 AC 154 ms
55,808 KB
testcase_17 AC 182 ms
55,956 KB
testcase_18 AC 168 ms
55,752 KB
testcase_19 AC 187 ms
56,032 KB
testcase_20 AC 135 ms
55,816 KB
testcase_21 AC 136 ms
55,980 KB
testcase_22 AC 129 ms
55,680 KB
testcase_23 AC 127 ms
55,720 KB
testcase_24 AC 127 ms
55,676 KB
testcase_25 AC 126 ms
56,020 KB
testcase_26 AC 184 ms
56,316 KB
testcase_27 AC 189 ms
55,832 KB
testcase_28 AC 189 ms
56,040 KB
testcase_29 AC 190 ms
55,884 KB
testcase_30 AC 187 ms
56,412 KB
testcase_31 AC 128 ms
55,828 KB
testcase_32 AC 127 ms
55,676 KB
testcase_33 AC 189 ms
56,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int eated = 0, not_eated = 0, prev_eated = 0, prev_not_eated = 0;
		
		for(int i = 0; i < N; i++){
			final int v = sc.nextInt();
			
			eated = prev_not_eated + v;
			not_eated = Math.max(prev_eated, prev_not_eated);
			
			prev_eated = eated;
			prev_not_eated = not_eated;
		}
		
		System.out.println(Math.max(prev_eated, prev_not_eated));
		
	}
	
}
0