結果

問題 No.489 株に挑戦
ユーザー latte0119latte0119
提出日時 2017-02-24 22:33:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 1,646 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 153,376 KB
実行使用メモリ 8,116 KB
最終ジャッジ日時 2023-09-27 04:53:56
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
7,856 KB
testcase_01 AC 25 ms
7,460 KB
testcase_02 AC 3 ms
7,256 KB
testcase_03 AC 3 ms
7,204 KB
testcase_04 AC 3 ms
7,144 KB
testcase_05 AC 4 ms
7,328 KB
testcase_06 AC 3 ms
7,188 KB
testcase_07 AC 3 ms
7,264 KB
testcase_08 AC 4 ms
7,260 KB
testcase_09 AC 3 ms
7,148 KB
testcase_10 AC 4 ms
6,060 KB
testcase_11 AC 3 ms
7,320 KB
testcase_12 AC 3 ms
7,152 KB
testcase_13 AC 3 ms
7,208 KB
testcase_14 AC 3 ms
7,188 KB
testcase_15 AC 5 ms
7,264 KB
testcase_16 AC 37 ms
7,856 KB
testcase_17 AC 8 ms
7,152 KB
testcase_18 AC 25 ms
7,524 KB
testcase_19 AC 19 ms
7,528 KB
testcase_20 AC 41 ms
7,848 KB
testcase_21 AC 12 ms
7,140 KB
testcase_22 AC 7 ms
7,460 KB
testcase_23 AC 28 ms
7,524 KB
testcase_24 AC 50 ms
7,940 KB
testcase_25 AC 4 ms
7,152 KB
testcase_26 AC 38 ms
8,052 KB
testcase_27 AC 48 ms
7,936 KB
testcase_28 AC 3 ms
7,248 KB
testcase_29 AC 4 ms
7,152 KB
testcase_30 AC 43 ms
8,116 KB
testcase_31 AC 38 ms
7,948 KB
testcase_32 AC 29 ms
7,416 KB
testcase_33 AC 47 ms
8,116 KB
testcase_34 AC 45 ms
7,792 KB
testcase_35 AC 19 ms
7,472 KB
testcase_36 AC 9 ms
7,268 KB
testcase_37 AC 26 ms
7,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

struct segtree{
    static const int SEG=1<<17;
    vector<pint>dat;
    segtree(vint &x):dat(SEG*2){
        for(int i=0;i<x.size();i++){
            dat[i+SEG-1].fi=x[i];
        }
        for(int i=0;i<SEG;i++){
            dat[i+SEG-1].se=i;
        }
        for(int i=SEG-2;i>=0;i--){
            dat[i]=min(dat[i*2+1],dat[i*2+2]);
        }
    }
    pint query(int a,int b,int k=0,int l=0,int r=SEG){
        if(r<=a||b<=l)return pint(INT_MAX,INT_MAX);
        if(a<=l&&r<=b)return dat[k];
        return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
    }
};

signed main(){
    int N,D,K;
    cin>>N>>D>>K;
    vint X(N);rep(i,N)cin>>X[i];

    int ans=0;
    pint a;
    segtree seg(X);

    for(int i=1;i<N;i++){
        int l=max(0ll,i-D);
        pint p=seg.query(l,i);
        if(ans<X[i]-p.fi){
            ans=X[i]-p.fi;
            a=pint(p.se,i);
        }
        else if(ans==X[i]-p.fi){
            chmin(a,pint(p.se,i));
        }
    }

    if(ans==0)cout<<0<<endl;
    else{
        cout<<ans*K<<endl;
        cout<<a.fi<<" "<<a.se<<endl;
    }
    return 0;
}
0