結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-05-09 21:23:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,039 bytes |
| コンパイル時間 | 781 ms |
| コンパイル使用メモリ | 76,564 KB |
| 実行使用メモリ | 8,832 KB |
| 最終ジャッジ日時 | 2024-09-14 20:06:50 |
| 合計ジャッジ時間 | 3,595 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 1 TLE * 1 -- * 33 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
int main() {
int N, D, K;
int T = 1000;
cin >> N >> D >> K;
T = (int)sqrt(N);
int X[100000], Table[1000], Index[1000];
for (int i = 0; i < N; i++) {
cin >> X[i];
if (Table[i / T] < X[i]) {
Table[i / T] = X[i];
Index[i / T] = i;
}
}
int ans = 0;
int ansL = -1, ansR = -1;
for (int i = 0; i < N - 1; i++) {
int right = min(i + D, N - 1);
int max = 0;
int r = -1;
for (int j = i + 1; j <= right && j % T <= T - 1; j++) {
if (max < X[j]) {
max = X[j];
r = j;
}
}
for (int j = i / T + 1; j < right / T; j++) {
if (max < Table[j]) {
max = Table[j];
r = Index[j];
}
}
for (int j = right; j >= i && j % T != T - 1; j--) {
if (max <= X[j]) {
max = X[j];
r = j;
}
}
if (ans < max - X[i]) {
ans = max - X[i];
ansL = i;
ansR = r;
}
}
cout << (long long)ans*K << endl;
if (ans == 0)return 0;
cout << ansL << " " << ansR << endl;
}
mban