結果
問題 | No.489 株に挑戦 |
ユーザー | zimpha |
提出日時 | 2017-03-25 19:07:01 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 288 ms / 1,000 ms |
コード長 | 2,422 bytes |
コンパイル時間 | 2,754 ms |
コンパイル使用メモリ | 78,116 KB |
実行使用メモリ | 47,892 KB |
最終ジャッジ日時 | 2024-07-19 23:45:27 |
合計ジャッジ時間 | 11,357 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 265 ms
47,832 KB |
testcase_01 | AC | 250 ms
47,212 KB |
testcase_02 | AC | 121 ms
41,440 KB |
testcase_03 | AC | 121 ms
41,140 KB |
testcase_04 | AC | 53 ms
37,148 KB |
testcase_05 | AC | 122 ms
41,124 KB |
testcase_06 | AC | 125 ms
40,888 KB |
testcase_07 | AC | 123 ms
40,884 KB |
testcase_08 | AC | 122 ms
41,308 KB |
testcase_09 | AC | 124 ms
41,100 KB |
testcase_10 | AC | 125 ms
41,300 KB |
testcase_11 | AC | 127 ms
41,392 KB |
testcase_12 | AC | 128 ms
41,336 KB |
testcase_13 | AC | 125 ms
41,420 KB |
testcase_14 | AC | 125 ms
41,328 KB |
testcase_15 | AC | 176 ms
42,060 KB |
testcase_16 | AC | 262 ms
47,852 KB |
testcase_17 | AC | 207 ms
44,480 KB |
testcase_18 | AC | 236 ms
47,416 KB |
testcase_19 | AC | 232 ms
47,248 KB |
testcase_20 | AC | 279 ms
47,720 KB |
testcase_21 | AC | 225 ms
45,252 KB |
testcase_22 | AC | 192 ms
41,972 KB |
testcase_23 | AC | 255 ms
46,928 KB |
testcase_24 | AC | 282 ms
47,892 KB |
testcase_25 | AC | 53 ms
37,148 KB |
testcase_26 | AC | 197 ms
43,972 KB |
testcase_27 | AC | 278 ms
47,200 KB |
testcase_28 | AC | 120 ms
41,296 KB |
testcase_29 | AC | 53 ms
36,972 KB |
testcase_30 | AC | 280 ms
47,820 KB |
testcase_31 | AC | 274 ms
47,440 KB |
testcase_32 | AC | 251 ms
47,080 KB |
testcase_33 | AC | 288 ms
47,744 KB |
testcase_34 | AC | 278 ms
47,848 KB |
testcase_35 | AC | 232 ms
46,888 KB |
testcase_36 | AC | 206 ms
42,952 KB |
testcase_37 | AC | 255 ms
47,368 KB |
ソースコード
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()); } } }