結果
問題 | No.489 株に挑戦 |
ユーザー |
|
提出日時 | 2017-02-24 22:40:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 1,000 ms |
コード長 | 799 bytes |
コンパイル時間 | 904 ms |
コンパイル使用メモリ | 87,244 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 22:55:34 |
合計ジャッジ時間 | 2,048 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <iostream>#include <cstdio>#include <algorithm>#include <string>#include <vector>#include <set>#include <map>#include <deque>#include <tuple>using namespace std;int main() {int n, d, k;cin >> n >> d >> k;vector<int> x(n);for (int i = 0; i < n; i++) {scanf("%d", &x[i]);}deque<int> q;tuple<int, int, int> mx(0, 0, 0);for (int i = 0; i < n; i++) {while (!q.empty() && i - q.front() > d) {q.pop_front();}while (!q.empty() && x[q.back()] > x[i]) {q.pop_back();}if (!q.empty()) {mx = max(mx, make_tuple(x[i] - x[q.front()], -q.front(), -i));}q.push_back(i);}int foo, bar, baz;tie(foo, bar, baz) = mx;if (foo == 0) {cout << 0 << endl;} else {cout << 1LL * foo * k << endl;cout << -bar << " " << -baz << endl;}}