結果

問題 No.489 株に挑戦
ユーザー togatogatogatoga
提出日時 2017-02-24 22:45:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,820 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 122,696 KB
実行使用メモリ 8,212 KB
最終ジャッジ日時 2023-08-30 23:33:17
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 34 ms
4,884 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N,D,K;
vector<int> X;
int main() {
  cin >> N >> D >> K;
  X.resize(N);
  for (auto &val : X){
    cin >> val;
  }
  ll res = 0;
  priority_queue<pii, vector<pii>, greater<pii>> pque;
  set<int> deleted;
  pii d(INF, INF);
  for (int i = 0; i < N; i++){
    int val = X[i];
    int buy_val,idx;
    buy_val = INF;
    idx = -1;
    while (not pque.empty()){
      pii p = pque.top();
      buy_val = p.first;
      idx = p.second;
      if (deleted.count(idx)){
        pque.pop();
        continue;
      }
      break;
    }
    ll tmp = (ll)(val - buy_val) * K;
    if (tmp > 0 and tmp >= res){
      res = tmp;
      if (tmp > res){
        d = mp(idx, i);
      }else{
        d = min(d, mp(idx, i));
      }
    }
    if (i - D >= 0){
      deleted.emplace(i - D);
    }
    pque.emplace(mp(val, i));
  }
  cout << res << endl;
  if (res != 0){
    cout << d.first << " " << d.second << endl;
  }
  return 0;
}
0