結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
4,932 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 24 ms
5,196 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 14 ms
4,404 KB
testcase_19 WA -
testcase_20 AC 29 ms
5,364 KB
testcase_21 AC 9 ms
4,376 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 19 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 29 ms
5,368 KB
testcase_27 AC 30 ms
5,368 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 WA -
testcase_31 AC 30 ms
5,368 KB
testcase_32 AC 19 ms
4,496 KB
testcase_33 AC 32 ms
5,376 KB
testcase_34 WA -
testcase_35 AC 13 ms
4,376 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 19 ms
4,380 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++;
  vector<ll> mx(N,0);
  {
    vector<ll> deq(N);
    int s=0,t=0;
    rep(i,N){
      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){
    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