結果

問題 No.489 株に挑戦
ユーザー TatsunoTatsuno
提出日時 2017-02-25 02:20:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,331 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 173,192 KB
実行使用メモリ 7,500 KB
最終ジャッジ日時 2023-09-01 22:01:47
合計ジャッジ時間 3,925 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
7,132 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 39 ms
7,152 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 27 ms
5,212 KB
testcase_19 WA -
testcase_20 AC 42 ms
7,128 KB
testcase_21 AC 10 ms
4,376 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 30 ms
5,140 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 34 ms
7,156 KB
testcase_27 AC 61 ms
7,184 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 41 ms
7,188 KB
testcase_32 AC 31 ms
5,108 KB
testcase_33 AC 51 ms
7,156 KB
testcase_34 WA -
testcase_35 AC 18 ms
5,076 KB
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 24 ms
5,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, d, k;

template <typename T, typename Cmp> struct segtree {
    i32 n; T defval; vec<T> data;
    segtree(i32 size, T default_value) : defval(default_value) { n=1; while(n<size) n*=2; data.resize(2*n-1, defval); }
    void update(i32 i, T x) {
        i += n-1; data[i] = x;
        while (i > 0) {
            i = (i-1)/2;
            data[i] = Cmp()(data[i*2+1], data[i*2+2]) ? data[i*2+1] : data[i*2+2];
        }
    }
    T query(i32 l, i32 r) {
        return _query(l, r, 0, 0, n);
    }
    T _query(i32 a, i32 b, i32 k, i32 l, i32 r) {
        if (r <= a || b <= l) return defval;
        if (a <= l && r <= b) return data[k];
        else {
            T vl = _query(a, b, k*2+1, l, (l+r)/2);
            T vr = _query(a, b, k*2+2, (l+r)/2, r);
            return Cmp()(vl, vr) ? vl : vr;
        }
    }
    T leaf(i32 i) { return data[i+n-1]; }
};

i32 main()
{
    cin >> n >> d >> k;
    using P = pair<i64, i32>;
    auto seg = segtree<P, greater<P>>(n, make_pair(-1, 1));
    i32 jj = 0, kk = 0; i64 dd = 0;
    times(n, i) {
        i32 x; cin >> x;
        seg.update(i, make_pair(x, -i));
    }
    times(n-d, i) {
        P x = seg.leaf(i);
        P maxx = seg.query(i+1, i+d+1);
        if (maxx.first - x.first > dd) {
            dd = maxx.first - x.first;
            jj = i;
            kk = -maxx.second;
        }
    }

    if (dd == 0) {
        cout << 0 << endl;
    } else {
        cout << dd*k << endl;
        cout << jj << " " << kk << endl;
    }
    return 0;
}
0