結果

問題 No.489 株に挑戦
ユーザー noynotenoynote
提出日時 2017-02-25 00:10:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,498 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 151,616 KB
実行使用メモリ 8,668 KB
最終ジャッジ日時 2023-08-31 01:04:04
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 58 ms
5,640 KB
testcase_17 AC 5 ms
4,384 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 51 ms
7,976 KB
testcase_27 AC 39 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 1 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:61:51: warning: ‘day[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(dif * k > 0) cout << day[0] << ' ' << day[1] << endl;
                                                   ^

ソースコード

diff #

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;


int main(){
    int n, d, k;
    int a[100005];
    cin >> n >> d >> k;
    rep(i,n) cin >> a[i];
    d++;

    set<pair<int, int>> s;
    int i = 0, dif = 0;
    int day[2];

    rep(i,d){
        int temp = a[i] - a[0];
        if(temp > dif){
            dif = temp;
            day[0] = 0;
            day[1] = i;
        }
    }

    range(i,n - d,n){
        int temp = a[i] - a[n - d];
        if(temp > dif){
            dif = temp;
            day[0] = n - d - 1;
            day[1] = i;
        }

    }

    while(i != n){
        while(s.size() != d){
            s.insert(make_pair(a[i],i));
            i++;
        }

        int temp = (--s.end())->first - a[i - s.size()];
        //for(auto it:s){ cout << it.second<< endl; }
        //show(s.size()) show( s.begin()->first); show( (--s.end())->first);
        if(temp > dif){
            dif = temp;
            day[0] = i - s.size();
            day[1] = (--s.end())->second;
        }
        //show(a[i - d])
        s.erase(s.find(make_pair(a[i - d], i - d)));
    }


    cout << dif * k << endl;
    if(dif * k > 0) cout << day[0] << ' ' << day[1] << endl;
}
0