結果
| 問題 |
No.489 株に挑戦
|
| ユーザー |
|
| 提出日時 | 2025-01-27 18:17:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 1,000 ms |
| コード長 | 1,699 bytes |
| コンパイル時間 | 2,001 ms |
| コンパイル使用メモリ | 162,300 KB |
| 実行使用メモリ | 19,648 KB |
| 最終ジャッジ日時 | 2025-01-27 18:17:20 |
| 合計ジャッジ時間 | 3,784 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include<bits/stdc++.h>
#define lowbit(x) x & (-x)
#define pi pair<ll, ll>
#define ls(k) k << 1
#define rs(k) k << 1 | 1
#define fi first
#define se second
#define int long long
using namespace std;
typedef __int128 __;
typedef long double lb;
typedef double db;
typedef unsigned long long ull;
typedef long long ll;
const int N = 1e5 + 10, M = 19;
inline ll read(){
ll x = 0, f = 1;
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-')
f = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return x * f;
}
inline void write(ll x){
if(x < 0){
putchar('-');
x = -x;
}
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
int n, d, k, now, ans = -1e18;
int a[N], F[M][N], lg[N];
inline int ask(int l, int r){
r = min(r, n);
int k = lg[r - l + 1];
return max(F[k][l], F[k][r - (1 << k) + 1]);
}
signed main(){
// freopen("stock.in", "r", stdin);
// freopen("stock.out", "w", stdout);
lg[0] = -1;
n = read(), d = read(), k = read();
for(int i = 1; i <= n; ++i){
a[i] = F[0][i] = read();
lg[i] = lg[i >> 1] + 1;
}
for(int j = 1; j < M; ++j)
for(int i = 1; i + (1 << j) - 1 <= n; ++i)
F[j][i] = max(F[j - 1][i], F[j - 1][i + (1 << (j - 1))]);
for(int i = 1; i < n; ++i){
if(ask(i + 1, min(i + d, n)) - a[i] > ans){
ans = ask(i + 1, min(i + d, n)) - a[i];
now = i;
}
}
if(ans <= 0){
puts("0");
return 0;
}
write(ans * k);
putchar('\n');
write(now - 1);
putchar(' ');
int t = ask(now + 1, min(now + d, n));
for(int i = now + 1; i <= n; ++i){
if(a[i] == t){
write(i - 1);
putchar('\n');
exit(0);
}
}
return 0;
}