結果

問題 No.489 株に挑戦
ユーザー btk
提出日時 2017-02-24 23:09:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 978 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 173,772 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 23:02:18
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

struct cww{cww(){
    ios::sync_with_stdio(false);cin.tie(0);
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
int deq[2123456];
int main(){
    LL N,D,K;
    cin>>N>>D>>K;
    vector<LL> x(N);
    cin>>x;
    using T=tuple<LL,int,int>;
    T res=T(0,0,0);
    int s=0,t=0;
    REP(i,N){
        while(s<t&&i-deq[s]>D)s++;
        while(s<t&&x[deq[t-1]]>x[i])t--;
        deq[t++]=i;
        chmin(res,T(x[deq[s]]-x[i],deq[s],i));
    }
    LL val;
    tie(val,s,t)=res;
    cout<<val*-K<<endl;
    if(val)cout<<s<<" "<<t<<endl;
    return 0;
}
0