結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
cormoran
|
| 提出日時 | 2017-02-24 23:09:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,299 bytes |
| コンパイル時間 | 1,736 ms |
| コンパイル使用メモリ | 171,712 KB |
| 実行使用メモリ | 9,800 KB |
| 最終ジャッジ日時 | 2025-01-02 23:44:25 |
| 合計ジャッジ時間 | 3,921 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 RE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> bool set_max(T &a, const T &b) { return a < b ? a = b, true : false; }
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
class Solver {
public:
bool solve() {
int N, D, K; cin >> N >> D >> K;
vector<int> X(N); cin >> X;
map<int, pii> val;
int max_diff = 0;
int j = -1, k = -1;
rep(i, N) {
if(!val.count(X[i])) val[X[i]].second = i;
val[X[i]].first++;
if(set_max(max_diff, X[i] - val.begin()->first)) {
j = val.begin()->second.second;
k = i;
assert(k - j <= D);
}
if(i >= D) {
if(--val[X[i - D]].first == 0) {
val.erase(X[i - D]);
}
}
}
cout << (ll)max_diff * K << endl;
if(max_diff > 0) {
assert(j >= 0 and k >= 0 and j < k);
cout << j << " " << k << endl;
}
return 0;
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
Solver s;
s.solve();
return 0;
}
cormoran