結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2017-10-16 07:29:42 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 200 ms / 5,000 ms |
| コード長 | 533 bytes |
| コンパイル時間 | 4,517 ms |
| コンパイル使用メモリ | 83,600 KB |
| 実行使用メモリ | 42,312 KB |
| 最終ジャッジ日時 | 2024-12-27 17:37:16 |
| 合計ジャッジ時間 | 11,631 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
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]));
}
}