結果

問題 No.489 株に挑戦
ユーザー Konton7Konton7
提出日時 2020-02-07 22:49:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 1,000 ms
コード長 2,038 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 205,640 KB
実行使用メモリ 5,528 KB
最終ジャッジ日時 2023-09-27 06:06:53
合計ジャッジ時間 4,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
4,604 KB
testcase_01 AC 18 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 26 ms
4,528 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 12 ms
4,376 KB
testcase_20 AC 31 ms
4,740 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 19 ms
4,376 KB
testcase_24 AC 34 ms
4,992 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 29 ms
4,912 KB
testcase_27 AC 30 ms
4,864 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 35 ms
4,844 KB
testcase_31 AC 31 ms
5,528 KB
testcase_32 AC 20 ms
4,376 KB
testcase_33 AC 34 ms
4,736 KB
testcase_34 AC 28 ms
4,588 KB
testcase_35 AC 13 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


struct player
{
    string name;
    int time;
    int total;
    vector<int> points;
};

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, k, a, t, l, r, d;
    ll ans;
    cin >> n >> k >> ans;
    k++;
    int num[n];
    vector<PII> minprice, maxprice;
    deque<PII> deqmin, deqmax;

    rep(i, n)
    {
        cin >> a;
        t = k + i;

        while (!deqmin.empty())
        {
            if (deqmin.front().second <= i)
                deqmin.pop_front();
            else
                break;
        }
        while (!deqmin.empty())
        {
            if (deqmin.back().first > a)
                deqmin.pop_back();
            else
                break;
        }
        deqmin.push_back(make_pair(a, t));

        while (!deqmax.empty())
        {

            if (deqmax.front().second < deqmin.front().second)
                deqmax.pop_front();
            else
                break;
        }

        while (!deqmax.empty())
        {
            if (deqmax.back().first < a)
                deqmax.pop_back();
            else
                break;
        }
        deqmax.push_back(make_pair(a, t));

        minprice.push_back(deqmin.front());
        maxprice.push_back(deqmax.front());
        // for (auto z : deqmin)
        //     cout << z.first << " ";
        // cout << endl;
    }

    d = 0;
    rep(i, n)
    {
        if (d < maxprice[i].first - minprice[i].first)
        {
            d = maxprice[i].first - minprice[i].first;
            l = minprice[i].second - k; 
            r = maxprice[i].second - k; 
        }
    }
    cout << ans * d << endl;
    if (d != 0)
        cout << l << " " << r <<endl;

    return 0;
}
0