結果
問題 | No.489 株に挑戦 |
ユーザー |
![]() |
提出日時 | 2017-02-24 22:58:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 61 ms / 1,000 ms |
コード長 | 1,680 bytes |
コンパイル時間 | 1,204 ms |
コンパイル使用メモリ | 85,012 KB |
実行使用メモリ | 6,016 KB |
最終ジャッジ日時 | 2024-07-19 23:01:17 |
合計ジャッジ時間 | 3,075 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <algorithm>#include <utility>#include <functional>#include <cstring>#include <queue>#include <stack>#include <math.h>#include <iterator>#include <vector>#include <string>#include <set>#include <math.h>#include <iostream>#include<map>#include <iomanip>#include <stdlib.h>#include <list>#include <typeinfo>#include <list>#include <set>using namespace std;#define MAX_MOD 1000000007#define REP(i,n) for(long long i = 0;i < n;++i)long long x[600000] = {};long long seg[600000] = {};long long setter(long long now) {seg[now] = max(seg[now * 2], seg[now * 2 + 1]);if (now != 1) {long long wow = setter(now / 2);}return 0;}long long find(long long now, long long n_l,long long n_r,long long w_l,long long w_r) {if (n_r - 1 <= w_l || w_r < n_l) return -1;if (w_l <= n_l&&n_r-1 <= w_r) return seg[now];long long aaa = find(now*2,n_l,(n_l+n_r)/2,w_l,w_r);aaa = max(aaa,find(now*2+1,(n_l+n_r)/2,n_r,w_l,w_r));return aaa;}#define nya 131072int main() {long long n, d, k;cin >> n >> d >> k;REP(i, n) {cin >> x[i];seg[nya+i] = x[i];setter((nya+i)/2);}long long hoge = 0;long long left = -1;for (int i = 0;i < n;++i) {long long maxium = find(1, 0, nya + 1, i, i + d);if (hoge < (maxium - x[i])) {hoge = maxium - x[i];left = i;}}if (left == -1) {cout << 0 << endl;return 0;}cout << hoge*k << endl;cout << left << " ";long long max_now = 0;long long max_right = 0;for (int q = 0;q <= d;++q) {if (max_now < x[q + left]) {max_now = x[q + left];max_right = q + left;}}cout << max_right << endl;return 0;}