結果

問題 No.45 回転寿司
ユーザー k_kadorak_kadora
提出日時 2015-06-22 22:52:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 191 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 4,636 ms
コンパイル使用メモリ 73,976 KB
実行使用メモリ 56,764 KB
最終ジャッジ日時 2023-08-27 14:06:49
合計ジャッジ時間 11,780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
56,076 KB
testcase_01 AC 183 ms
55,880 KB
testcase_02 AC 191 ms
56,312 KB
testcase_03 AC 191 ms
56,764 KB
testcase_04 AC 184 ms
56,140 KB
testcase_05 AC 136 ms
56,176 KB
testcase_06 AC 168 ms
56,052 KB
testcase_07 AC 176 ms
55,968 KB
testcase_08 AC 157 ms
56,104 KB
testcase_09 AC 184 ms
55,660 KB
testcase_10 AC 177 ms
56,152 KB
testcase_11 AC 146 ms
55,724 KB
testcase_12 AC 183 ms
56,116 KB
testcase_13 AC 134 ms
56,416 KB
testcase_14 AC 133 ms
55,924 KB
testcase_15 AC 167 ms
56,264 KB
testcase_16 AC 151 ms
56,008 KB
testcase_17 AC 173 ms
56,224 KB
testcase_18 AC 154 ms
56,264 KB
testcase_19 AC 182 ms
56,060 KB
testcase_20 AC 132 ms
56,064 KB
testcase_21 AC 133 ms
55,708 KB
testcase_22 AC 127 ms
55,948 KB
testcase_23 AC 126 ms
55,888 KB
testcase_24 AC 126 ms
53,936 KB
testcase_25 AC 126 ms
55,892 KB
testcase_26 AC 178 ms
56,444 KB
testcase_27 AC 183 ms
56,388 KB
testcase_28 AC 173 ms
56,296 KB
testcase_29 AC 183 ms
56,332 KB
testcase_30 AC 180 ms
56,168 KB
testcase_31 AC 125 ms
55,904 KB
testcase_32 AC 126 ms
56,084 KB
testcase_33 AC 182 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Yuki45{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int n,res=0;
		n = sc.nextInt();
		int[] v = new int[n+1];
		for(int i = 1;i<n+1;i++){
			v[i] = sc.nextInt();
		}
		int[][] dp = new int[2][n+1];
		for(int i = 1;i<n+1;i++){
			if(dp[0][i-1]<dp[1][i-1]){
				dp[0][i] = dp[1][i-1];
			}else{
				dp[0][i] = dp[0][i-1];
			}
			dp[1][i] = dp[0][i-1] + v[i];
		}
		if(dp[0][n]>dp[1][n]){
			res = dp[0][n];
		}else{
			res = dp[1][n];
		}
		System.out.println(res);
	}
}
0