結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-24 22:39:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 800 bytes |
| コンパイル時間 | 1,275 ms |
| コンパイル使用メモリ | 83,888 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-02 23:10:32 |
| 合計ジャッジ時間 | 2,516 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d", &x[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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;
}
}