結果

問題 No.489 株に挑戦
ユーザー PachicobuePachicobue
提出日時 2017-03-16 09:37:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,557 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 79,040 KB
実行使用メモリ 8,848 KB
最終ジャッジ日時 2023-09-17 05:05:54
合計ジャッジ時間 7,403 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0