結果

問題 No.45 回転寿司
ユーザー dogwood0424dogwood0424
提出日時 2017-12-06 16:46:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 548 bytes
コンパイル時間 2,792 ms
コンパイル使用メモリ 73,560 KB
実行使用メモリ 57,732 KB
最終ジャッジ日時 2023-08-27 15:52:57
合計ジャッジ時間 8,972 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
55,612 KB
testcase_01 AC 163 ms
56,124 KB
testcase_02 AC 163 ms
56,220 KB
testcase_03 AC 164 ms
56,452 KB
testcase_04 AC 155 ms
56,208 KB
testcase_05 AC 120 ms
55,928 KB
testcase_06 AC 156 ms
55,956 KB
testcase_07 AC 157 ms
56,164 KB
testcase_08 AC 143 ms
57,732 KB
testcase_09 AC 158 ms
55,836 KB
testcase_10 AC 156 ms
56,464 KB
testcase_11 AC 128 ms
55,712 KB
testcase_12 AC 165 ms
56,288 KB
testcase_13 AC 120 ms
55,980 KB
testcase_14 AC 116 ms
56,280 KB
testcase_15 AC 147 ms
55,872 KB
testcase_16 AC 134 ms
53,736 KB
testcase_17 AC 150 ms
56,136 KB
testcase_18 AC 132 ms
55,892 KB
testcase_19 AC 169 ms
56,724 KB
testcase_20 AC 112 ms
55,900 KB
testcase_21 AC 118 ms
56,036 KB
testcase_22 AC 106 ms
55,728 KB
testcase_23 AC 108 ms
53,884 KB
testcase_24 AC 110 ms
56,228 KB
testcase_25 AC 110 ms
55,760 KB
testcase_26 AC 153 ms
56,224 KB
testcase_27 AC 161 ms
56,004 KB
testcase_28 AC 159 ms
56,120 KB
testcase_29 AC 159 ms
56,152 KB
testcase_30 AC 161 ms
56,012 KB
testcase_31 AC 110 ms
56,072 KB
testcase_32 AC 111 ms
55,916 KB
testcase_33 AC 166 ms
56,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No45
{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int n  = sc.nextInt();	//最初の入力
		int []v=new int [n+1];	//美味しさを格納する配列
		v[0]=0;
		for(int i=1;i<n+1;i++) {
			v[i]=sc.nextInt();	//美味しさの入力
		}

		int[]c = new int[n+1];	//c[i]はi番目までの美味しさの最大値

		c[0]=0;
		c[1]=v[1];



		for(int i=2;i<n+1;i++) {

				c[i]+=Math.max(c[i-1], c[i-2]+v[i]);

			}

		System.out.println(c[n]);

		sc.close();

	}

}
0