結果

問題 No.45 回転寿司
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-18 00:57:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 201 ms / 5,000 ms
コード長 564 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 72,200 KB
実行使用メモリ 57,188 KB
最終ジャッジ日時 2023-08-27 16:40:49
合計ジャッジ時間 9,125 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
56,316 KB
testcase_01 AC 182 ms
56,160 KB
testcase_02 AC 196 ms
56,804 KB
testcase_03 AC 201 ms
56,424 KB
testcase_04 AC 186 ms
56,788 KB
testcase_05 AC 130 ms
55,984 KB
testcase_06 AC 183 ms
56,412 KB
testcase_07 AC 193 ms
56,556 KB
testcase_08 AC 150 ms
56,092 KB
testcase_09 AC 199 ms
56,580 KB
testcase_10 AC 155 ms
56,192 KB
testcase_11 AC 142 ms
54,196 KB
testcase_12 AC 198 ms
56,444 KB
testcase_13 AC 130 ms
55,892 KB
testcase_14 AC 127 ms
56,172 KB
testcase_15 AC 184 ms
56,816 KB
testcase_16 AC 156 ms
56,288 KB
testcase_17 AC 181 ms
57,188 KB
testcase_18 AC 145 ms
56,428 KB
testcase_19 AC 194 ms
57,064 KB
testcase_20 AC 132 ms
55,648 KB
testcase_21 AC 133 ms
53,944 KB
testcase_22 AC 123 ms
56,236 KB
testcase_23 AC 123 ms
56,016 KB
testcase_24 AC 124 ms
55,888 KB
testcase_25 AC 122 ms
55,780 KB
testcase_26 AC 187 ms
56,668 KB
testcase_27 AC 190 ms
56,560 KB
testcase_28 AC 183 ms
54,672 KB
testcase_29 AC 195 ms
56,736 KB
testcase_30 AC 192 ms
56,808 KB
testcase_31 AC 120 ms
56,108 KB
testcase_32 AC 121 ms
55,876 KB
testcase_33 AC 198 ms
56,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int v[]=new int[n];
		for(int i=0;i<n;i++){
			v[i]=scanner.nextInt();
		}
		if(n==1){
			System.out.println(v[0]);
			return;
		}
		int dp[]=new int[n];
		dp[0]=v[0];
		dp[1]=v[1];
		for(int i=0;i<n;i++){
			for(int j=0;j<i-1;j++){
				dp[i]=Math.max(dp[i], dp[j]+v[i]);
			}
		}
		Arrays.sort(dp);
		System.out.println(dp[dp.length-1]);
	}
}
0