結果

問題 No.45 回転寿司
ユーザー spaciaspacia
提出日時 2016-01-04 17:18:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 71,808 KB
実行使用メモリ 49,728 KB
最終ジャッジ日時 2023-08-27 14:33:34
合計ジャッジ時間 5,358 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
49,200 KB
testcase_01 AC 50 ms
49,444 KB
testcase_02 AC 52 ms
49,564 KB
testcase_03 AC 53 ms
49,460 KB
testcase_04 AC 52 ms
49,508 KB
testcase_05 AC 47 ms
49,312 KB
testcase_06 AC 50 ms
49,464 KB
testcase_07 AC 52 ms
49,304 KB
testcase_08 AC 49 ms
49,332 KB
testcase_09 AC 53 ms
49,464 KB
testcase_10 AC 49 ms
49,464 KB
testcase_11 AC 48 ms
49,320 KB
testcase_12 AC 53 ms
49,364 KB
testcase_13 AC 46 ms
49,260 KB
testcase_14 AC 48 ms
49,304 KB
testcase_15 AC 50 ms
49,464 KB
testcase_16 AC 49 ms
49,320 KB
testcase_17 AC 50 ms
49,412 KB
testcase_18 AC 50 ms
49,436 KB
testcase_19 AC 51 ms
49,272 KB
testcase_20 AC 46 ms
49,492 KB
testcase_21 AC 46 ms
49,312 KB
testcase_22 AC 47 ms
49,180 KB
testcase_23 AC 46 ms
49,500 KB
testcase_24 AC 47 ms
49,396 KB
testcase_25 AC 46 ms
49,372 KB
testcase_26 AC 48 ms
49,728 KB
testcase_27 AC 52 ms
49,428 KB
testcase_28 AC 50 ms
49,444 KB
testcase_29 AC 52 ms
49,208 KB
testcase_30 AC 53 ms
49,208 KB
testcase_31 AC 45 ms
49,400 KB
testcase_32 AC 46 ms
49,272 KB
testcase_33 AC 52 ms
49,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		int[] v = new int[n];
		int[] d = new int[n];
		String[] s = br.readLine().split(" ");
		
		for (int i = 0; i < n; i++)
			v[i] = Integer.parseInt(s[i]);
		
		d[0] = v[0];
		if (n >= 2) d[1] = Math.max(v[0] , v[1]);
		for (int i = 2; i < n; i++)
			d[i] = Math.max(d[i - 1] , d[i - 2] + v[i]);
		
		out(d[n - 1]);
		
	}
}
0