結果

問題 No.489 株に挑戦
コンテスト
ユーザー Bantako
提出日時 2017-08-18 14:37:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,387 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 174,468 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-14 14:55:53
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<int, int> p;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    ll N,D,K,X[100000];
    cin >> N >> D >> K;
    for(int i = 0;i < N;i++)cin >> X[i];
    int minn = INF,maxn = 0,maxd = 0,mini,maxi;
    priority_queue<p> bq;//降順
    priority_queue<p,vector<p>,greater<p> > sq;//昇順
    for(int i = 0;i <= D;i++){
        bq.push(p(X[i],i));
        sq.push(p(X[i],i));
        /*
        if(minn > X[i]){
            minn = X[i];
            mini = i;
        }
        if(maxn < X[i]){
            maxn = X[i];
            maxi = i;
        }
        maxd = max(maxd,maxn-minn);
        */
        while(bq.top().second < sq.top().second){
            sq.pop();
        }
        if(maxd < bq.top().first-sq.top().first){
            maxd = bq.top().first-sq.top().first;
            maxi = bq.top().second;
            mini = sq.top().second;
        }
    }
    for(int i = D+1;i < N;i++){
        bq.push(p(X[i],i));
        sq.push(p(X[i],i));
        while(bq.top().second <= i-D)bq.pop();
        while(sq.top().second <= i-D)sq.pop();
        if(maxd < bq.top().first-sq.top().first){
            maxd = bq.top().first-sq.top().first;
            maxi = bq.top().second;
            mini = sq.top().second;
        }
    }
    cout << maxd*K << endl;
    if(maxd)cout << mini << " " << maxi << endl;
}
0