結果

問題 No.489 株に挑戦
ユーザー どららどらら
提出日時 2017-02-24 23:24:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 34 ms / 1,000 ms
コード長 1,161 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 148,796 KB
実行使用メモリ 7,824 KB
最終ジャッジ日時 2023-09-27 05:08:19
合計ジャッジ時間 2,846 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
4,768 KB
testcase_01 AC 17 ms
5,236 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 23 ms
6,236 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 11 ms
4,540 KB
testcase_20 AC 28 ms
6,164 KB
testcase_21 AC 8 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 17 ms
4,468 KB
testcase_24 AC 34 ms
6,488 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 32 ms
7,824 KB
testcase_27 AC 28 ms
5,600 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 33 ms
7,652 KB
testcase_31 AC 31 ms
7,656 KB
testcase_32 AC 19 ms
4,712 KB
testcase_33 AC 33 ms
6,272 KB
testcase_34 AC 28 ms
5,468 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 18 ms
5,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  ll N, D, K;
  cin >> N >> D >> K;
  vector<ll> x;
  rep(i,N){
    ll a;
    cin >> a;
    x.push_back(a);
  }

  D++;
  rep(i,D){
    x.push_back(0);
  }
  
  vector<ll> mx(x.size(),0);
  {
    vector<ll> deq(x.size());
    int s=0,t=0;
    rep(i,x.size()){
      while(s<t && x[deq[t-1]]<=x[i]) t--;
      deq[t++] = i;

      if(i-D+1 >= 0){
        mx[i-D+1] = x[deq[s]];
        if(deq[s] == i-D+1) s++;
      }
    }
  }

  ll best = 0;
  int best_i = 0;
  rep(i,N){
    //cout << x[i] << " " << mx[i] << endl;
    if(mx[i]-x[i]>best){
      best = mx[i]-x[i];
      best_i = i;
    }
  }
  if(best == 0){
    cout << 0 << endl;
  }else{
    cout << best*K << endl;
    cout << best_i << " ";
    REP(i,best_i,best_i+D){
      if(x[i] == mx[best_i]){
        cout << i;
        break;
      }
    }
    cout << endl;
  }

  
  return 0;
}

0