結果
問題 | No.489 株に挑戦 |
ユーザー |
|
提出日時 | 2024-07-31 02:41:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,000 ms |
コード長 | 723 bytes |
コンパイル時間 | 2,752 ms |
コンパイル使用メモリ | 252,188 KB |
実行使用メモリ | 8,932 KB |
最終ジャッジ日時 | 2024-07-31 02:41:51 |
合計ジャッジ時間 | 5,079 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/segtree>using namespace std;using namespace atcoder;using ll = long long;using T = pair<ll, ll>;T op(T l, T r) { return max(l, r); }T e() { return {0, 0}; }int main() {ios::sync_with_stdio(false);cin.tie(nullptr);ll N, D, K;cin >> N >> D >> K;vector<pair<ll, ll>> v(N);for(ll i = 0; i < N; i++) {cin >> v[i].first;v[i].second = -i;}segtree<T, op, e> S(v);ll ans = 0, l, r;for(ll i = 0; i < N; i++) {auto [val, idx] = S.prod(i, min(i + D + 1, N));if(val - v[i].first > ans) {ans = val - v[i].first;tie(l, r) = {i, idx};}}cout << ans * K << "\n";if(ans) { cout << l << " " << -r << "\n"; }}