結果
| 問題 | No.45 回転寿司 |
| ユーザー |
|
| 提出日時 | 2017-05-04 21:25:06 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 236 ms / 5,000 ms |
| コード長 | 593 bytes |
| 記録 | |
| コンパイル時間 | 3,485 ms |
| コンパイル使用メモリ | 73,816 KB |
| 実行使用メモリ | 42,100 KB |
| 最終ジャッジ日時 | 2024-12-27 16:18:52 |
| 合計ジャッジ時間 | 12,241 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]);
}
}