結果

問題 No.489 株に挑戦
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-17 03:03:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 579 ms / 1,000 ms
コード長 711 bytes
コンパイル時間 3,287 ms
コンパイル使用メモリ 76,408 KB
実行使用メモリ 61,144 KB
最終ジャッジ日時 2023-09-27 06:01:27
合計ジャッジ時間 17,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 529 ms
60,864 KB
testcase_01 AC 456 ms
60,856 KB
testcase_02 AC 142 ms
56,748 KB
testcase_03 AC 142 ms
57,104 KB
testcase_04 AC 117 ms
56,116 KB
testcase_05 AC 141 ms
57,104 KB
testcase_06 AC 143 ms
56,952 KB
testcase_07 AC 146 ms
57,008 KB
testcase_08 AC 141 ms
57,088 KB
testcase_09 AC 144 ms
56,656 KB
testcase_10 AC 146 ms
56,836 KB
testcase_11 AC 147 ms
57,248 KB
testcase_12 AC 148 ms
56,792 KB
testcase_13 AC 148 ms
57,000 KB
testcase_14 AC 146 ms
58,896 KB
testcase_15 AC 231 ms
59,820 KB
testcase_16 AC 516 ms
60,960 KB
testcase_17 AC 289 ms
60,752 KB
testcase_18 AC 431 ms
60,952 KB
testcase_19 AC 409 ms
60,392 KB
testcase_20 AC 520 ms
60,808 KB
testcase_21 AC 356 ms
61,036 KB
testcase_22 AC 258 ms
60,024 KB
testcase_23 AC 468 ms
61,144 KB
testcase_24 AC 533 ms
61,108 KB
testcase_25 AC 124 ms
55,516 KB
testcase_26 AC 495 ms
60,444 KB
testcase_27 AC 529 ms
58,704 KB
testcase_28 AC 139 ms
56,760 KB
testcase_29 AC 117 ms
56,656 KB
testcase_30 AC 579 ms
61,064 KB
testcase_31 AC 512 ms
60,556 KB
testcase_32 AC 455 ms
60,904 KB
testcase_33 AC 514 ms
60,804 KB
testcase_34 AC 526 ms
60,592 KB
testcase_35 AC 385 ms
60,968 KB
testcase_36 AC 294 ms
60,972 KB
testcase_37 AC 449 ms
60,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No489{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int D = sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0; i < N; i++){
			x[i] = sc.nextInt();
		}
		int[] q = new int[N];
		int h = 0, t = -1;
		int diff = 0, a = 0, b = 0;
		for(int i = 0; i < N; i++){
			while(t >= h && q[h] < i-D) ++h;
			if(t >= h && x[i]-x[q[h]] > diff){
				diff = x[i] - x[q[h]];
				a = q[h];
				b = i;
			}
			while(t >= h && x[q[t]] > x[i]){
				--t;
			}

			q[++t] = i;
		}
		if(diff == 0) System.out.println(0);
		else{
			System.out.println((long)K*diff);
			System.out.println(a + " " + b);
		}
	}
}
0