結果

問題 No.489 株に挑戦
ユーザー BantakoBantako
提出日時 2018-06-20 22:30:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,781 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 175,068 KB
実行使用メモリ 23,192 KB
最終ジャッジ日時 2023-09-13 07:24:51
合計ジャッジ時間 3,711 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
22,508 KB
testcase_01 AC 23 ms
12,636 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 39 ms
22,912 KB
testcase_17 AC 6 ms
5,268 KB
testcase_18 AC 20 ms
12,528 KB
testcase_19 AC 19 ms
12,216 KB
testcase_20 AC 43 ms
22,896 KB
testcase_21 AC 11 ms
7,620 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 25 ms
12,524 KB
testcase_24 AC 48 ms
23,184 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 45 ms
23,036 KB
testcase_27 WA -
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 48 ms
23,192 KB
testcase_31 AC 45 ms
22,992 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 7 ms
5,156 KB
testcase_37 AC 24 ms
12,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:44:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   44 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
template <typename T>
struct SparseTable
{
    vector<vector<T>> st;
    vector<int> lookup;

    SparseTable(const vector<T> &v)
    {
        int b = 0;
        while ((1 << b) <= v.size())
            ++b;
        st.assign(b, vector<T>(1 << b));
        for (int i = 0; i < v.size(); i++)
        {
            st[0][i] = v[i];
        }
        for (int i = 1; i < b; i++)
        {
            for (int j = 0; j + (1 << i) <= (1 << b); j++)
            {
                st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
            }
        }
        lookup.resize(v.size() + 1);
        for (int i = 2; i < lookup.size(); i++)
        {
            lookup[i] = lookup[i >> 1] + 1;
        }
    }

    inline T rmq(int l, int r)
    {
        int b = lookup[r - l];
        return min(st[b][l], st[b][r - (1 << b)]);
    }
};
main(){
    ll N,D,K;
    cin >> N >> D >> K;
    vector<ll> X(N),v(N);    
    rep(i, 0, N){
        cin >> X[i];
    }    
    SparseTable<ll> table(X);

    rep(i,0,N){
        if(i - D >= 0){
            v[i] = table.rmq(i-D,i+1);
        }else{
            v[i] = table.rmq(0,i+1);
        }
    }
    /*
    for(auto i:v){
        cout << i << " ";
    }cout << endl;
    */
    ll maxd = 0,ml,mr,l = 0,r;
    rep(i,0,N){
        //if(i - l >= D && v[i] == X[i])l = i;
        if(i && v[i] == X[i] && v[i-1] != v[i])l = i;
        if(X[i] - v[i] > maxd){
            maxd = X[i] - v[i];
            ml = l;
            mr = i;
        }
    }
    if(maxd == 0) cout << 0 << endl;
    else cout << maxd * K << endl << ml << " " << mr << endl;
}
0