結果

問題 No.489 株に挑戦
ユーザー simansiman
提出日時 2022-11-11 12:32:08
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,087 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 107,788 KB
実行使用メモリ 5,984 KB
最終ジャッジ日時 2023-10-11 09:27:52
合計ジャッジ時間 2,667 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
5,756 KB
testcase_01 AC 19 ms
4,564 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 26 ms
5,868 KB
testcase_17 AC 6 ms
4,348 KB
testcase_18 AC 16 ms
4,492 KB
testcase_19 AC 14 ms
4,496 KB
testcase_20 AC 32 ms
5,912 KB
testcase_21 AC 9 ms
4,348 KB
testcase_22 AC 4 ms
4,352 KB
testcase_23 AC 21 ms
4,572 KB
testcase_24 AC 37 ms
5,984 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 35 ms
5,940 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,352 KB
testcase_30 AC 37 ms
5,948 KB
testcase_31 AC 33 ms
5,984 KB
testcase_32 AC 20 ms
4,604 KB
testcase_33 AC 35 ms
5,912 KB
testcase_34 AC 31 ms
5,896 KB
testcase_35 AC 14 ms
4,416 KB
testcase_36 AC 6 ms
4,352 KB
testcase_37 AC 20 ms
4,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

struct Node {
  int day;
  ll x;

  Node(int day = -1, ll x = -1) {
    this->day = day;
    this->x = x;
  }

  bool operator>(const Node &n) const {
    return x > n.x;
  }
};

int main() {
  ll N, D, K;
  cin >> N >> D >> K;

  priority_queue <Node, vector<Node>, greater<Node>> pque;
  ll X[N];
  for (int i = 0; i < N; ++i) {
    cin >> X[i];
  }
  pque.push(Node(0, X[0]));
  ll ans = 0;
  int j = -1;
  int k = -1;

  for (int day = 1; day <= N - 1; ++day) {
    ll x = X[day];

    while (day - pque.top().day > D) {
      pque.pop();
    }

    ll diff = x - pque.top().x;
    if (ans < diff * K) {
      ans = diff * K;
      j = pque.top().day;
      k = day;
    }

    pque.push(Node(day, x));
  }

  if (ans == 0) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
    cout << j << " " << k << endl;
  }

  return 0;
}
0