結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-12-06 05:21:48 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 493 bytes |
| コンパイル時間 | 2,361 ms |
| コンパイル使用メモリ | 74,408 KB |
| 実行使用メモリ | 54,540 KB |
| 最終ジャッジ日時 | 2024-11-28 01:22:17 |
| 合計ジャッジ時間 | 9,277 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 RE * 1 |
| other | AC * 24 WA * 6 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
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 [] dp = new int [N];
dp[0]=V[0];
dp[1]=V[1];
for(int i=2; i<N; i++){
dp[i]=Math.max(dp[i-1],dp[i-2]+V[i]);
}
System.out.println(Math.max(dp[N-1],dp[N-2]));
}
}
kohaku_kohaku