結果

問題 No.45 回転寿司
ユーザー kenji_shioyakenji_shioya
提出日時 2016-05-26 17:12:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 181 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 3,197 ms
コンパイル使用メモリ 71,816 KB
実行使用メモリ 56,572 KB
最終ジャッジ日時 2023-08-27 14:54:04
合計ジャッジ時間 9,881 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
56,036 KB
testcase_01 AC 173 ms
55,936 KB
testcase_02 AC 171 ms
56,160 KB
testcase_03 AC 174 ms
56,100 KB
testcase_04 AC 172 ms
56,300 KB
testcase_05 AC 132 ms
56,040 KB
testcase_06 AC 160 ms
56,220 KB
testcase_07 AC 181 ms
55,676 KB
testcase_08 AC 157 ms
56,572 KB
testcase_09 AC 176 ms
56,540 KB
testcase_10 AC 166 ms
56,164 KB
testcase_11 AC 136 ms
55,560 KB
testcase_12 AC 175 ms
56,116 KB
testcase_13 AC 130 ms
56,024 KB
testcase_14 AC 129 ms
55,304 KB
testcase_15 AC 164 ms
55,892 KB
testcase_16 AC 152 ms
55,936 KB
testcase_17 AC 167 ms
54,108 KB
testcase_18 AC 143 ms
55,456 KB
testcase_19 AC 173 ms
55,948 KB
testcase_20 AC 132 ms
55,540 KB
testcase_21 AC 134 ms
55,824 KB
testcase_22 AC 120 ms
55,300 KB
testcase_23 AC 121 ms
56,176 KB
testcase_24 AC 121 ms
55,500 KB
testcase_25 AC 120 ms
55,488 KB
testcase_26 AC 165 ms
56,116 KB
testcase_27 AC 164 ms
56,088 KB
testcase_28 AC 168 ms
56,348 KB
testcase_29 AC 171 ms
56,104 KB
testcase_30 AC 174 ms
56,224 KB
testcase_31 AC 121 ms
55,812 KB
testcase_32 AC 118 ms
55,880 KB
testcase_33 AC 174 ms
56,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercises20{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int numberOfSushi = sc.nextInt();

    int[] sushiArray = new int[numberOfSushi];

    for (int n = 0; n < numberOfSushi; n++){
      sushiArray[n] = sc.nextInt();
    }

    int[] dp = new int[2];
    for (int n = 0; n < numberOfSushi; n++){
      int[] dp2 = new int[2];
      dp2[0] = Math.max(dp[0], dp[1]);
      dp2[1] = dp[0] + sushiArray[n];
      dp = dp2;
    }

    System.out.println(Math.max(dp[0], dp[1]));
  }
}
0