結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
togatoga
|
| 提出日時 | 2017-02-24 22:45:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,820 bytes |
| コンパイル時間 | 1,474 ms |
| コンパイル使用メモリ | 119,792 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2025-01-02 23:21:00 |
| 合計ジャッジ時間 | 3,834 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 5 WA * 30 |
ソースコード
#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;
}
togatoga