結果

問題 No.1104 オンライン点呼
ユーザー ks2mks2m
提出日時 2020-07-03 22:04:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 936 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 68,040 KB
最終ジャッジ日時 2023-10-17 03:21:31
合計ジャッジ時間 7,652 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
53,596 KB
testcase_01 AC 249 ms
67,208 KB
testcase_02 AC 280 ms
67,916 KB
testcase_03 AC 266 ms
67,832 KB
testcase_04 AC 50 ms
53,596 KB
testcase_05 AC 50 ms
53,596 KB
testcase_06 AC 50 ms
51,588 KB
testcase_07 AC 184 ms
63,512 KB
testcase_08 AC 132 ms
59,768 KB
testcase_09 AC 207 ms
65,876 KB
testcase_10 AC 48 ms
53,588 KB
testcase_11 AC 167 ms
60,308 KB
testcase_12 AC 186 ms
63,564 KB
testcase_13 AC 185 ms
61,048 KB
testcase_14 AC 89 ms
55,016 KB
testcase_15 AC 239 ms
63,544 KB
testcase_16 WA -
testcase_17 AC 194 ms
63,668 KB
testcase_18 AC 226 ms
65,984 KB
testcase_19 AC 262 ms
67,084 KB
testcase_20 AC 271 ms
67,156 KB
testcase_21 AC 259 ms
68,040 KB
testcase_22 AC 278 ms
67,188 KB
testcase_23 AC 222 ms
65,912 KB
testcase_24 AC 159 ms
58,156 KB
testcase_25 AC 49 ms
53,596 KB
testcase_26 AC 49 ms
53,588 KB
testcase_27 AC 48 ms
53,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);

		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}

		sa = br.readLine().split(" ");
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		long[] dp = new long[n];
		for (int i = 1; i < n; i++) {
			dp[i] = dp[i - 1] + a[i - 1] + b[i];
			if (i > 1) {
				long val = dp[i - 2] + a[i - 2] + b[i] + k;
				dp[i] = Math.min(dp[i], val);
			}
		}

		long ans = 0;
		for (int i = 0; i < dp.length; i++) {
			ans = Math.max(ans, dp[i]);
		}
		System.out.println(ans);
	}
}
0