結果
問題 | No.489 株に挑戦 |
ユーザー |
![]() |
提出日時 | 2017-03-09 23:29:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 1,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 806 ms |
コンパイル使用メモリ | 78,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 23:41:38 |
合計ジャッジ時間 | 2,322 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <iostream>#include <vector>#include <deque>#include <utility>#include <algorithm>using namespace std;typedef pair<int, int> pii;#define mp make_pairint main() {int n, d, k; cin >> n >> d >> k;vector<int> x(n);for (int i = 0; i < n; i++) cin >> x[i];deque<pii> dq;dq.push_back(mp(x[0], 0));pair<int, int> ansp;int ansv = 0;for (int i = 1; i < n; i++) {while (dq.size() != 0 && dq.back() > mp(x[i], i)) dq.pop_back();dq.push_back(mp(x[i], i));while (i - dq.front().second > d) dq.pop_front();if (x[i] - dq.front().first > ansv) {ansv = x[i] - dq.front().first;ansp = mp(dq.front().second, i);}}if (ansv <= 0) {cout << 0 << endl;}else {cout << (long long)ansv*k << endl;cout << ansp.first << " " << ansp.second << endl;}return 0;}