結果

問題 No.45 回転寿司
ユーザー core123core123
提出日時 2019-04-17 14:01:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 207 ms / 5,000 ms
コード長 1,143 bytes
コンパイル時間 2,940 ms
コンパイル使用メモリ 75,860 KB
実行使用メモリ 57,856 KB
最終ジャッジ日時 2023-08-27 16:58:20
合計ジャッジ時間 9,725 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
55,944 KB
testcase_01 AC 179 ms
56,324 KB
testcase_02 AC 189 ms
56,812 KB
testcase_03 AC 179 ms
56,620 KB
testcase_04 AC 176 ms
56,156 KB
testcase_05 AC 126 ms
55,936 KB
testcase_06 AC 174 ms
56,420 KB
testcase_07 AC 186 ms
56,756 KB
testcase_08 AC 140 ms
55,920 KB
testcase_09 AC 190 ms
56,704 KB
testcase_10 AC 154 ms
56,116 KB
testcase_11 AC 135 ms
57,856 KB
testcase_12 AC 194 ms
56,680 KB
testcase_13 AC 126 ms
55,864 KB
testcase_14 AC 131 ms
55,804 KB
testcase_15 AC 180 ms
55,824 KB
testcase_16 AC 143 ms
55,808 KB
testcase_17 AC 171 ms
56,360 KB
testcase_18 AC 150 ms
55,908 KB
testcase_19 AC 207 ms
56,340 KB
testcase_20 AC 123 ms
55,856 KB
testcase_21 AC 129 ms
55,960 KB
testcase_22 AC 120 ms
55,848 KB
testcase_23 AC 120 ms
55,764 KB
testcase_24 AC 117 ms
55,832 KB
testcase_25 AC 117 ms
55,420 KB
testcase_26 AC 174 ms
56,432 KB
testcase_27 AC 182 ms
56,324 KB
testcase_28 AC 180 ms
56,856 KB
testcase_29 AC 185 ms
56,288 KB
testcase_30 AC 183 ms
56,568 KB
testcase_31 AC 118 ms
56,088 KB
testcase_32 AC 117 ms
55,848 KB
testcase_33 AC 191 ms
57,176 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(Arrays.stream(dp).max().orElse(0));
		
	}
	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