結果

問題 No.489 株に挑戦
ユーザー zimphazimpha
提出日時 2017-03-25 18:58:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,423 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 62,384 KB
最終ジャッジ日時 2023-09-20 10:44:53
合計ジャッジ時間 11,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
60,532 KB
testcase_01 AC 234 ms
60,312 KB
testcase_02 AC 111 ms
56,120 KB
testcase_03 AC 111 ms
55,820 KB
testcase_04 AC 42 ms
49,412 KB
testcase_05 AC 111 ms
55,716 KB
testcase_06 AC 114 ms
56,032 KB
testcase_07 AC 112 ms
55,588 KB
testcase_08 AC 110 ms
56,092 KB
testcase_09 AC 110 ms
55,432 KB
testcase_10 AC 111 ms
56,124 KB
testcase_11 AC 110 ms
55,620 KB
testcase_12 AC 112 ms
55,324 KB
testcase_13 AC 112 ms
55,700 KB
testcase_14 AC 116 ms
55,644 KB
testcase_15 AC 162 ms
55,904 KB
testcase_16 AC 245 ms
60,320 KB
testcase_17 AC 183 ms
58,240 KB
testcase_18 AC 234 ms
60,756 KB
testcase_19 AC 224 ms
60,404 KB
testcase_20 AC 270 ms
60,184 KB
testcase_21 AC 209 ms
60,684 KB
testcase_22 AC 175 ms
56,496 KB
testcase_23 AC 237 ms
60,432 KB
testcase_24 AC 275 ms
60,000 KB
testcase_25 AC 44 ms
49,464 KB
testcase_26 AC 184 ms
55,136 KB
testcase_27 WA -
testcase_28 AC 107 ms
55,752 KB
testcase_29 AC 42 ms
49,500 KB
testcase_30 AC 276 ms
60,508 KB
testcase_31 AC 252 ms
60,056 KB
testcase_32 AC 236 ms
60,500 KB
testcase_33 AC 274 ms
58,260 KB
testcase_34 AC 258 ms
60,592 KB
testcase_35 AC 211 ms
61,188 KB
testcase_36 AC 185 ms
58,000 KB
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Chiaki.Hoshinomori
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task489 solver = new Task489();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task489 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int d = in.nextInt();
            int k = in.nextInt();
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
            }
            int[] q = new int[n];
            int h = 0, t = -1;
            int ret = 0, a = 0, b = 0;
            for (int i = 0; i < n; i++) {
                while (h <= t && q[h] < i - d) ++h;
                if (h <= t && x[i] - x[q[h]] > ret) {
                    ret = x[i] - x[q[h]];
                    a = q[h];
                    b = i;
                }
                while (h <= t && x[q[t]] >= x[i]) --t;
                q[++t] = i;
            }
            if (ret == 0) out.println(ret);
            else out.printf("%d\n%d %d\n", (long) k * ret, a, b);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

0