結果

問題 No.489 株に挑戦
ユーザー cormorancormoran
提出日時 2017-02-24 23:15:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 1,000 ms
コード長 1,481 bytes
コンパイル時間 1,842 ms
コンパイル使用メモリ 179,096 KB
実行使用メモリ 76,968 KB
最終ジャッジ日時 2023-09-27 05:06:46
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
4,380 KB
testcase_01 AC 63 ms
26,184 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 50 ms
10,744 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 33 ms
6,112 KB
testcase_19 AC 24 ms
9,600 KB
testcase_20 AC 121 ms
36,436 KB
testcase_21 AC 25 ms
16,232 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 26 ms
4,376 KB
testcase_24 AC 139 ms
33,936 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 102 ms
69,588 KB
testcase_27 AC 10 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 156 ms
73,492 KB
testcase_31 AC 98 ms
76,968 KB
testcase_32 AC 40 ms
5,748 KB
testcase_33 AC 129 ms
30,540 KB
testcase_34 AC 79 ms
12,544 KB
testcase_35 AC 31 ms
9,888 KB
testcase_36 AC 14 ms
11,728 KB
testcase_37 AC 69 ms
31,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }

class Solver {
  public:
    bool solve() {
        int N, D, K; cin >> N >> D >> K;
        vector<int> X(N); cin >> X;

        map<int, pair<int, queue<int>>> val;
        int max_diff = 0, j = -1, k = -1;
        rep(i, N) {
            int x = X[i];
            val[x].second.push(i);
            val[x].first++;
            if(set_max(max_diff, x - begin(val)->first)) {
                j = val.begin()->second.second.front();
                k = i;
                // assert(k - j <= D);
            }
            if(i >= D) {
                assert(val.count(X[i - D]));
                if(--val[X[i - D]].first == 0) {
                    val.erase(X[i - D]);                    
                } else {
                    val[X[i - D]].second.pop();                            
                }
            }
        }
        cout << (ll)max_diff * K << endl;
        if(max_diff > 0) {
            assert(j >= 0 and k >= 0 and j < k);
            cout << j << " " << k << endl;
        }
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0