結果

問題 No.45 回転寿司
ユーザー spaciaspacia
提出日時 2016-01-04 17:16:19
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 640 bytes
コンパイル時間 3,619 ms
コンパイル使用メモリ 75,740 KB
実行使用メモリ 37,068 KB
最終ジャッジ日時 2024-05-03 11:26:15
合計ジャッジ時間 4,837 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
37,068 KB
testcase_01 AC 53 ms
36,928 KB
testcase_02 AC 55 ms
36,848 KB
testcase_03 AC 53 ms
36,776 KB
testcase_04 AC 53 ms
36,848 KB
testcase_05 AC 50 ms
36,636 KB
testcase_06 AC 52 ms
36,924 KB
testcase_07 AC 52 ms
36,880 KB
testcase_08 AC 51 ms
36,648 KB
testcase_09 AC 54 ms
36,628 KB
testcase_10 AC 52 ms
36,776 KB
testcase_11 AC 52 ms
36,524 KB
testcase_12 AC 53 ms
37,008 KB
testcase_13 AC 50 ms
36,776 KB
testcase_14 AC 52 ms
36,724 KB
testcase_15 AC 51 ms
36,912 KB
testcase_16 AC 52 ms
36,864 KB
testcase_17 AC 51 ms
36,872 KB
testcase_18 AC 51 ms
37,008 KB
testcase_19 AC 52 ms
37,056 KB
testcase_20 AC 50 ms
36,952 KB
testcase_21 AC 53 ms
36,900 KB
testcase_22 AC 50 ms
36,908 KB
testcase_23 AC 50 ms
36,888 KB
testcase_24 AC 52 ms
36,860 KB
testcase_25 RE -
testcase_26 AC 52 ms
36,776 KB
testcase_27 AC 52 ms
36,976 KB
testcase_28 AC 52 ms
37,028 KB
testcase_29 AC 53 ms
37,016 KB
testcase_30 AC 52 ms
36,904 KB
testcase_31 AC 53 ms
36,784 KB
testcase_32 AC 51 ms
36,848 KB
testcase_33 AC 53 ms
37,012 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];
		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