結果

問題 No.2150 Site Supporter
ユーザー tentententen
提出日時 2023-03-03 08:33:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 1,860 bytes
コンパイル時間 5,654 ms
コンパイル使用メモリ 83,560 KB
実行使用メモリ 58,228 KB
最終ジャッジ日時 2023-10-18 00:48:29
合計ジャッジ時間 12,975 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,848 KB
testcase_01 AC 51 ms
36,856 KB
testcase_02 AC 51 ms
36,872 KB
testcase_03 AC 51 ms
36,868 KB
testcase_04 AC 50 ms
36,856 KB
testcase_05 AC 50 ms
36,840 KB
testcase_06 AC 51 ms
36,828 KB
testcase_07 AC 51 ms
36,872 KB
testcase_08 AC 167 ms
42,756 KB
testcase_09 AC 299 ms
57,024 KB
testcase_10 AC 249 ms
48,228 KB
testcase_11 AC 278 ms
55,616 KB
testcase_12 AC 201 ms
46,992 KB
testcase_13 AC 171 ms
45,124 KB
testcase_14 AC 51 ms
36,876 KB
testcase_15 AC 51 ms
36,824 KB
testcase_16 AC 50 ms
36,856 KB
testcase_17 AC 304 ms
58,228 KB
testcase_18 AC 238 ms
48,200 KB
testcase_19 AC 136 ms
41,648 KB
testcase_20 AC 255 ms
51,256 KB
testcase_21 AC 127 ms
40,052 KB
testcase_22 AC 292 ms
57,028 KB
testcase_23 AC 51 ms
36,844 KB
testcase_24 AC 53 ms
36,940 KB
testcase_25 AC 51 ms
36,852 KB
testcase_26 AC 51 ms
36,836 KB
testcase_27 AC 252 ms
51,868 KB
testcase_28 AC 241 ms
48,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        long[][] dp = new long[n][2];
        dp[0][0] = sc.nextInt();
        dp[0][1] = k + x;
        for (int i = 1; i < n; i++) {
            dp[i][0] = Math.min(dp[i - 1][0], dp[i - 1][1]) + sc.nextInt();
            dp[i][1] = Math.min(dp[i - 1][0] + x, dp[i - 1][1]) + k;
        }
        System.out.println(Math.min(dp[n - 1][0], dp[n - 1][1]));
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0