結果

問題 No.489 株に挑戦
ユーザー konsin_tokage
提出日時 2018-06-04 06:50:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 65,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 09:31:39
合計ジャッジ時間 3,067 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <deque>
using namespace std;
#define ll long long
int main(){
    ll n, d, K;
    cin >> n >> d >> K;
    vector<ll> x(n);
    for(ll& e: x) cin >> e;
    deque<int> q;
    int j = 0, k = 0;
    ll r = 0;
    for(int i=0; i<n; ++i){
        while(q.size() && x[q.back()]<x[i]) q.pop_back();
        q.push_back(i);
        if(q.front() == i-d) q.pop_front();
        if(i>=d && x[q.front()]-x[i-d]>r){
            j = i-d;
            k = q.front();
            r = x[k] - x[j];
        }
    }
    cout << r*K << endl;
    if(r) cout << j << " " << k << endl;
}
0