結果

問題 No.489 株に挑戦
ユーザー konsin_tokage
提出日時 2018-05-31 06:48:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 98 ms / 1,000 ms
コード長 609 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 69,820 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-07-20 00:02:53
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define ll long long
int main(){
    ll n,d,K,m=0,j=0,k=0;
    cin>>n>>d>>K;
    vector<ll> x(n);
    for(ll &i:x) cin>>i;
    set<pair<ll,ll>> s;
    for(ll i=0;i<=d;++i) s.insert({x[i],i});
    for(ll i=0;i<n;++i){
        auto p = s.upper_bound({(--s.end())->first-1,n});
        if(p->first-x[i]>m){
            m=p->first-x[i];
            j=i;
            k=p->second;
        }
        s.erase({x[i],i});
        if(i+d+1<n) s.insert({x[i+d+1],i+d+1});
    }
    cout<<m*K<<endl;
    if(m) cout<<j<<" "<<k<<endl;
    return 0;
}
0