結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-25 10:47:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 850 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 68,292 KB |
| 実行使用メモリ | 9,812 KB |
| 最終ジャッジ日時 | 2024-12-17 22:37:30 |
| 合計ジャッジ時間 | 2,318 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 WA * 1 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long int ll;
const ll N = 100000;
ll n, d, k, mx[N],p[N];
int ct[1000000] = {};
int mx_i = 0;
int main() {
cin >> n >> d >> k;
for (int i = 0; i < n; i++)cin >> p[i];
mx[n - 1] = p[n - 1];
priority_queue<ll> mxq;
mxq.push(p[n - 1]);
ct[p[n - 1]]++;
for (int i = n - 2; i >= 0; i--) {
mxq.push(p[i]);
ct[p[i]]++;
if (i + d + 1 < n)ct[p[i + d + 1]]--;
for (; ct[mxq.top()] == 0; mxq.pop());
mx[i] = mxq.top();
}
for (int i = 1; i < n; i++) {
if (mx[i] - p[i] > mx[mx_i] - p[mx_i])mx_i = i;
}
if (mx[mx_i] - p[mx_i] > 0) {
cout << k * (mx[mx_i] - p[mx_i]) << endl;
cout << mx_i << ' ';
for (int i = mx_i; i < n; i++) { if (p[i] == mx[mx_i]) { cout << i << endl; break; } }
}
else cout << 0 << endl;
return 0;
}