結果

問題 No.489 株に挑戦
ユーザー data9824data9824
提出日時 2017-02-26 16:23:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 66,388 KB
実行使用メモリ 7,460 KB
最終ジャッジ日時 2023-09-02 10:00:45
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
5,624 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,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 25 ms
5,764 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 31 ms
5,780 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 21 ms
6,348 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 33 ms
5,812 KB
testcase_27 AC 35 ms
7,460 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 34 ms
5,940 KB
testcase_32 AC 20 ms
4,728 KB
testcase_33 AC 34 ms
6,120 KB
testcase_34 WA -
testcase_35 AC 13 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 20 ms
4,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, d;
    long long k;
    cin >> n >> d >> k;
    long long x[1000000];
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    priority_queue<pair<long long, int> > max;
    for (int i = 0; i < d - 1; ++i) {
        max.push(make_pair(x[i], i));
    }
    long long maxProfit = 0;
    int maxIn = 0, maxOut = 0;
    for (int i = 0; i < n - d; ++i) {
        max.push(make_pair(x[i + d], i + d));
        while (max.top().second < i) {
            max.pop();
        }
        long long profit = max.top().first - x[i];
        if (maxProfit < profit) {
            maxProfit = profit;
            maxIn = i;
            maxOut = max.top().second;
        }
    }
    cout << (maxProfit * k) << endl;
    if (maxProfit > 0) {
        cout << maxIn << " " << maxOut << endl;
    }
    return 0;
}
0