結果
| 問題 | No.45 回転寿司 |
| ユーザー |
|
| 提出日時 | 2017-05-04 21:25:06 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 1,839 ms |
| コンパイル使用メモリ | 81,852 KB |
| 実行使用メモリ | 45,728 KB |
| 最終ジャッジ日時 | 2026-06-02 04:26:31 |
| 合計ジャッジ時間 | 5,854 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
import java.util.Scanner;
/**
* Created by whiled on 17/05/04.
*/
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int[] v = new int[N];
for (int i=0; i<N; i++) v[i] = scan.nextInt();
int[] res = new int[N+1];
res[0] = 0;
res[1] = v[0];
if (res.length > 2) res[2] = Math.max(v[0], v[1]);
for (int i=2; i<res.length-1; i++){
res[i+1] = Math.max(res[i], res[i-1] + v[i]);
}
System.out.println(res[N]);
}
}