結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2017-02-24 22:48:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 1,000 ms |
| コード長 | 746 bytes |
| コンパイル時間 | 1,871 ms |
| コンパイル使用メモリ | 163,580 KB |
| 実行使用メモリ | 5,452 KB |
| 最終ジャッジ日時 | 2024-07-19 22:59:27 |
| 合計ジャッジ時間 | 3,644 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
typedef pair< int, int > Pi;
int N, D, K, X[100000];
int solve(int output = -INF)
{
priority_queue< Pi, vector< Pi >, greater< Pi > > que;
int ret = 0;
for(int i = 0; i < N; i++) {
while(!que.empty() && i - que.top().second > D) que.pop();
if(que.size()) {
ret = max(ret, X[i] - que.top().first);
if(ret > 0 && ret == output) {
cout << 1LL * (X[i] - que.top().first) * K << endl;
cout << que.top().second << " " << i << endl;
return (INF);
}
}
que.emplace(X[i], i);
}
return (ret);
}
int main()
{
cin >> N >> D >> K;
for(int i = 0; i < N; i++) cin >> X[i];
if(!solve(solve())) cout << 0 << endl;
}
ei1333333