結果

問題 No.489 株に挑戦
ユーザー どららどらら
提出日時 2017-02-24 23:37:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 151,832 KB
実行使用メモリ 5,648 KB
最終ジャッジ日時 2023-08-31 00:11:18
合計ジャッジ時間 4,579 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,460 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 25 ms
4,532 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 14 ms
4,380 KB
testcase_19 AC 12 ms
4,380 KB
testcase_20 AC 31 ms
4,720 KB
testcase_21 RE -
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 19 ms
4,380 KB
testcase_24 AC 35 ms
4,600 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 RE -
testcase_27 AC 31 ms
4,660 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 34 ms
4,584 KB
testcase_31 AC 31 ms
4,732 KB
testcase_32 AC 19 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 30 ms
4,476 KB
testcase_35 AC 13 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

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;

//x.size() > k, 
vector<ll> slide_max(const vector<ll>& x, int k){
  vector<ll> ret(x.size(), 0);
  deque<ll> deq;
  for(int i=0; i<x.size(); i++){
    while(deq.size()>0 && x[deq[deq.size()-1]]<=x[i]) deq.pop_back();
    deq.push_back(i);
    
    if(i-k+1 >= 0){
      ret[i-k+1] = x[deq[0]];
      if(deq[0] == i-k+1) deq.pop_front();
    }
  }
  //
  for(int i=x.size()-k+1; i<x.size(); i++){
    ret[i] = ret[x.size()-k];
  }
  return ret;
}

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++;
  
  vector<ll> mx = slide_max(x, D);
  
  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