結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-16 09:37:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,557 bytes |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 77,200 KB |
| 実行使用メモリ | 17,856 KB |
| 最終ジャッジ日時 | 2024-07-04 02:33:11 |
| 合計ジャッジ時間 | 5,975 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 34 |
ソースコード
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
// clang-format off
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
#define MAX 100000
int N, D, K;
int x[MAX];
pii ben[MAX];
bool comp(const pii& a, const pii& b)
{
if(a.fst < b.fst){
return true;
} else if(a.fst > b.fst){
return false;
} else {
if(a.snd > b.snd){
return true;
} else if (a.snd < b.snd){
return false;
} else {
return false;
}
}
}
int main()
{
cin >> N >> D >> K;
rep(i, N){
cin >> x[i];
}
vector<pii> mask(D+1);
for(int i = 0; i <= D; i++){
mask[i] = mp(x[i], i);
}
// [x[i-D-1],...,x[i-1]], x[i]
for(int i = D+1; i < N; i++){
sort(mask.begin(), mask.end(), comp);
ben[i-D-1] = mp(mask[D].fst - x[i-D-1], mask[D].snd);
auto ite = lower_bound(mask.begin(), mask.end(), mp(x[i-D-1], i-D-1), comp);
mask.erase(ite);
mask.pb(mp(x[i], i));
}
// [x[j],...,x[N-1]]
// [x[N-D-1],...,x[N-1]]
for(int j = N-D-1; j < N; j++){
sort(mask.begin(), mask.end(), comp);
ben[j] = mp(mask.back().fst - x[j], mask.back().snd);
auto ite = lower_bound(mask.begin(), mask.end(), mp(x[j], j), comp);
mask.erase(ite);
}
int max = 0;
int max_i = 0;
rep(i, N){
if(max < ben[i].fst){
max = ben[i].fst;
max_i = i;
}
}
if(ben[max_i].fst == 0){
cout << 0 << endl;
} else {
cout << (ll)(ben[max_i].fst) * (ll)(K) << endl;
cout << max_i << " " << ben[max_i].snd << endl;
}
return 0;
}