結果
問題 |
No.489 株に挑戦
|
ユーザー |
![]() |
提出日時 | 2017-02-26 16:23:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 935 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 66,668 KB |
実行使用メモリ | 13,264 KB |
最終ジャッジ日時 | 2024-06-11 16:43:13 |
合計ジャッジ時間 | 2,106 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 9 |
ソースコード
#include <iostream> #include <queue> #include <utility> using namespace std; int main(int argc, const char * argv[]) { int n, d; long long k; cin >> n >> d >> k; long long x[1000000]; for (int i = 0; i < n; ++i) { cin >> x[i]; } priority_queue<pair<long long, int> > max; for (int i = 0; i < d - 1; ++i) { max.push(make_pair(x[i], i)); } long long maxProfit = 0; int maxIn = 0, maxOut = 0; for (int i = 0; i < n - d; ++i) { max.push(make_pair(x[i + d], i + d)); while (max.top().second < i) { max.pop(); } long long profit = max.top().first - x[i]; if (maxProfit < profit) { maxProfit = profit; maxIn = i; maxOut = max.top().second; } } cout << (maxProfit * k) << endl; if (maxProfit > 0) { cout << maxIn << " " << maxOut << endl; } return 0; }