結果
問題 | No.489 株に挑戦 |
ユーザー |
![]() |
提出日時 | 2024-09-30 00:29:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 1,000 ms |
コード長 | 917 bytes |
コンパイル時間 | 1,433 ms |
コンパイル使用メモリ | 120,844 KB |
実行使用メモリ | 8,880 KB |
最終ジャッジ日時 | 2024-09-30 00:29:35 |
合計ジャッジ時間 | 3,601 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; #include<atcoder/segtree> pair<ll,ll> op(pair<ll,ll> a,pair<ll,ll> b){ return max(a,b); } pair<ll,ll> e(){ return make_pair(0,-1); } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n,d,k; cin>>n>>d>>k; atcoder::segtree<pair<ll,ll>,op,e> seg(n); vector<ll> x(n); for(int i = 0;i<n;i++){ cin>>x[i]; seg.set(i,make_pair(x[i],-i)); } ll ans = 0; int ni,nj; for(int i = 0;i<n;i++){ int ri = i + d + 1; ri = min<int>(ri,n); auto now = seg.prod(i,ri); ll p = now.first; if(p==x[i]) continue; ll can = k * (p-x[i]); if(can<=ans) continue; ans = can; ni = i; nj = -now.second; } cout<<ans<<endl; if(ans==0) return 0; cout<<ni<<" "<<nj<<endl; }