結果

問題 No.45 回転寿司
ユーザー core123core123
提出日時 2019-04-17 13:59:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,117 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 78,804 KB
実行使用メモリ 58,560 KB
最終ジャッジ日時 2023-10-22 07:21:56
合計ジャッジ時間 9,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
57,660 KB
testcase_01 AC 190 ms
57,808 KB
testcase_02 AC 200 ms
57,696 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 141 ms
57,640 KB
testcase_06 AC 191 ms
57,604 KB
testcase_07 WA -
testcase_08 AC 155 ms
57,704 KB
testcase_09 AC 199 ms
57,756 KB
testcase_10 AC 187 ms
57,720 KB
testcase_11 AC 150 ms
57,620 KB
testcase_12 WA -
testcase_13 AC 140 ms
57,396 KB
testcase_14 WA -
testcase_15 AC 185 ms
57,576 KB
testcase_16 AC 157 ms
55,812 KB
testcase_17 AC 182 ms
57,760 KB
testcase_18 AC 159 ms
57,384 KB
testcase_19 AC 201 ms
57,776 KB
testcase_20 AC 138 ms
57,620 KB
testcase_21 AC 144 ms
57,616 KB
testcase_22 AC 131 ms
57,224 KB
testcase_23 AC 130 ms
57,616 KB
testcase_24 AC 132 ms
57,608 KB
testcase_25 AC 130 ms
57,468 KB
testcase_26 AC 189 ms
57,632 KB
testcase_27 AC 208 ms
57,832 KB
testcase_28 AC 194 ms
57,808 KB
testcase_29 WA -
testcase_30 AC 197 ms
57,784 KB
testcase_31 AC 130 ms
57,664 KB
testcase_32 WA -
testcase_33 AC 209 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.stream.*;
import static java.lang.Math.*;
public class Main{
	public static void main(String... args){
		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[] dp=new int[n];
		for(int i=0;i<n;i++){
			dp[i]=v[i];
		}
		for(int i=0;i<n;i++){
			for(int j=i+2;j<n;j++){
				dp[j]=max(dp[j],dp[i]+v[j]);
			}
		}
		put(dp[n-1]);
		
	}
	public static class Pair{
		final int x,y;
		Pair(int x,int y){
			this.x=x;
			this.y=y;
		}
		@Override
		public String toString(){
			return String.format("Pair(%d,%d)",x,y);
		}
	}
	public static void print(Object object){
        System.out.print(object);
    }
    public static void put(Object object) {
        System.out.println(object);
    }
    public static void put(){
        System.out.println();
    }
 
    public static void print(String format,Object... args){
        System.out.print(String.format(format,args));
    }
    public static void put(String format,Object... args) {
        System.out.println(String.format(format,args));
    }
}
0