結果

問題 No.45 回転寿司
ユーザー holegumaholeguma
提出日時 2015-08-11 23:09:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 615 bytes
コンパイル時間 3,498 ms
コンパイル使用メモリ 71,540 KB
実行使用メモリ 49,860 KB
最終ジャッジ日時 2023-08-27 14:18:28
合計ジャッジ時間 5,090 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,492 KB
testcase_01 AC 44 ms
49,292 KB
testcase_02 AC 44 ms
49,556 KB
testcase_03 AC 46 ms
49,548 KB
testcase_04 AC 44 ms
49,860 KB
testcase_05 AC 41 ms
49,492 KB
testcase_06 AC 47 ms
49,640 KB
testcase_07 AC 48 ms
49,612 KB
testcase_08 AC 43 ms
49,304 KB
testcase_09 AC 47 ms
49,744 KB
testcase_10 AC 46 ms
49,604 KB
testcase_11 AC 42 ms
49,564 KB
testcase_12 AC 45 ms
49,392 KB
testcase_13 AC 42 ms
49,376 KB
testcase_14 AC 41 ms
49,276 KB
testcase_15 AC 44 ms
49,648 KB
testcase_16 AC 42 ms
47,224 KB
testcase_17 AC 45 ms
49,592 KB
testcase_18 AC 44 ms
49,260 KB
testcase_19 AC 44 ms
49,500 KB
testcase_20 AC 41 ms
49,396 KB
testcase_21 AC 42 ms
49,308 KB
testcase_22 AC 42 ms
49,408 KB
testcase_23 AC 43 ms
49,304 KB
testcase_24 AC 41 ms
49,568 KB
testcase_25 AC 41 ms
49,376 KB
testcase_26 AC 45 ms
49,536 KB
testcase_27 AC 45 ms
49,748 KB
testcase_28 AC 44 ms
49,260 KB
testcase_29 AC 45 ms
49,728 KB
testcase_30 AC 45 ms
49,392 KB
testcase_31 AC 40 ms
49,388 KB
testcase_32 AC 41 ms
49,364 KB
testcase_33 AC 47 ms
49,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] dp=new int[n+2];
int[] v=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) v[i]=Integer.parseInt(st.nextToken());
for(int i=n-1;i>=0;i--){
dp[i]=Math.max(dp[i+1],dp[i+2]+v[i]);
}
out.println(dp[0]);
out.flush();
}
}
}
0