結果

問題 No.45 回転寿司
ユーザー tetsutetsu
提出日時 2017-10-16 07:29:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 2,735 ms
コンパイル使用メモリ 73,124 KB
実行使用メモリ 56,756 KB
最終ジャッジ日時 2023-08-27 15:50:03
合計ジャッジ時間 8,921 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 151 ms
56,076 KB
testcase_01 AC 158 ms
56,552 KB
testcase_02 AC 155 ms
56,524 KB
testcase_03 AC 163 ms
56,128 KB
testcase_04 AC 154 ms
56,128 KB
testcase_05 AC 121 ms
55,624 KB
testcase_06 AC 153 ms
56,132 KB
testcase_07 AC 164 ms
56,432 KB
testcase_08 AC 127 ms
56,008 KB
testcase_09 AC 167 ms
56,072 KB
testcase_10 AC 155 ms
56,292 KB
testcase_11 AC 121 ms
55,392 KB
testcase_12 AC 163 ms
56,444 KB
testcase_13 AC 121 ms
55,588 KB
testcase_14 AC 116 ms
55,932 KB
testcase_15 AC 158 ms
56,400 KB
testcase_16 AC 132 ms
56,096 KB
testcase_17 AC 152 ms
56,100 KB
testcase_18 AC 138 ms
56,148 KB
testcase_19 AC 155 ms
56,612 KB
testcase_20 AC 119 ms
55,976 KB
testcase_21 AC 129 ms
55,684 KB
testcase_22 AC 116 ms
55,576 KB
testcase_23 AC 115 ms
55,596 KB
testcase_24 AC 117 ms
55,328 KB
testcase_25 AC 115 ms
56,096 KB
testcase_26 AC 160 ms
56,208 KB
testcase_27 AC 158 ms
56,144 KB
testcase_28 AC 160 ms
56,296 KB
testcase_29 AC 165 ms
56,228 KB
testcase_30 AC 177 ms
55,948 KB
testcase_31 AC 112 ms
56,036 KB
testcase_32 AC 112 ms
55,656 KB
testcase_33 AC 169 ms
56,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.*;

public class P45 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] V = new int[N];
		for(int i=0; i<N; i++) {
			V[i] = sc.nextInt();
		}
		int[] toru = new int[N];
		int[] toranai = new int[N];
		toru[0] = V[0];
		for(int i=1; i<N; i++) {
			toru[i] = toranai[i-1]+V[i];
			toranai[i] = Math.max(toru[i-1], toranai[i-1]);
		}
		System.out.println(Math.max(toru[N-1], toranai[N-1]));
	}

}
0