結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2017-02-24 22:49:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 86 ms / 1,000 ms |
| コード長 | 1,836 bytes |
| コンパイル時間 | 1,562 ms |
| コンパイル使用メモリ | 112,600 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-07-19 23:00:08 |
| 合計ジャッジ時間 | 3,634 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#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();
idx = p.second;
if (deleted.count(idx)){
pque.pop();
continue;
}
buy_val = p.first;
break;
}
ll tmp = (ll)(val - buy_val) * K;
if (tmp > 0 and tmp >= res){
if (tmp > res){
d = mp(idx, i);
}else if (tmp == res){
d = min(d, mp(idx, i));
}
res = tmp;
}
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;
}
togatoga