結果
| 問題 | 
                            No.45 回転寿司
                             | 
                    
| ユーザー | 
                             kenji_shioya
                         | 
                    
| 提出日時 | 2016-05-26 17:12:45 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 192 ms / 5,000 ms | 
| コード長 | 563 bytes | 
| コンパイル時間 | 3,383 ms | 
| コンパイル使用メモリ | 74,212 KB | 
| 実行使用メモリ | 42,672 KB | 
| 最終ジャッジ日時 | 2024-12-27 14:52:33 | 
| 合計ジャッジ時間 | 10,195 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
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]));
  }
}
            
            
            
        
            
kenji_shioya