結果

問題 No.1435 Mmm......
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-07-28 13:06:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,155 bytes
コンパイル時間 2,518 ms
コンパイル使用メモリ 201,956 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-15 21:48:19
合計ジャッジ時間 13,967 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 745 ms
11,776 KB
testcase_22 AC 654 ms
11,520 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>

using namespace std;
using namespace atcoder;
using ll = long long;

const int INF = 1e9+1;

struct S{
    int m1;
    int m2;
};

S op1(S a, S b){
    if(a.m1 < b.m1){
        if(a.m2 < b.m2){
            return a;
        }else{
            return {a.m1, b.m2};
        }
    }else{
        if(b.m2 < a.m1){
            return b;
        }else{
            return {b.m1, a.m1};
        }
    }
}

S e1(){
    return {INF, INF};
}

int op2(int a, int b){
    return max(a, b);
}

int e2(){
    return -INF;
}
 
int main(){
 
    int N, x, mx;
    cin >> N;
    S mi;
    vector<int> a(N);
    vector<S> b(N);
    ll ans=0;

    for (int i=0; i<N; i++){
        cin >> x;
        a[i] = x;
        b[i] = {x, INF};
    }
    segtree<int, op2, e2> tmx(a);
    segtree<S, op1, e1> tmi(b);

    for (int i=0; i<N; i++){
        int l=i, r=N, c;
        while(r-l>1){
            c = (l+r)/2;
            mi = tmi.prod(i, c+1);
            mx = tmx.prod(i, c+1);
            if (mx <= mi.m1 + mi.m2) l=c;
            else r=c;
        }
        ans += l-i;
    }

    cout << ans << endl;

    return 0;
}
0