結果

問題 No.45 回転寿司
ユーザー tetsu
提出日時 2017-10-16 07:29:42
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 103 ms / 5,000 ms
+ 27µs
コード長 533 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,373 ms
コンパイル使用メモリ 85,804 KB
実行使用メモリ 48,876 KB
最終ジャッジ日時 2026-10-08 16:43:07
合計ジャッジ時間 7,864 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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