結果

問題 No.1435 Mmm......
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-07-28 13:03:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,040 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 206,600 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-15 21:45:15
合計ジャッジ時間 24,605 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 903 ms
10,880 KB
testcase_07 AC 1,142 ms
11,264 KB
testcase_08 AC 1,368 ms
11,708 KB
testcase_09 AC 1,230 ms
11,392 KB
testcase_10 AC 1,077 ms
11,120 KB
testcase_11 AC 1,039 ms
11,136 KB
testcase_12 AC 987 ms
11,136 KB
testcase_13 AC 930 ms
11,016 KB
testcase_14 AC 661 ms
7,680 KB
testcase_15 AC 1,425 ms
11,776 KB
testcase_16 AC 1,140 ms
11,316 KB
testcase_17 AC 767 ms
7,680 KB
testcase_18 AC 1,484 ms
11,776 KB
testcase_19 AC 1,006 ms
11,136 KB
testcase_20 AC 1,296 ms
11,464 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 1,510 ms
11,904 KB
testcase_24 AC 1,501 ms
11,904 KB
testcase_25 AC 1,491 ms
11,904 KB
testcase_26 AC 1,505 ms
11,904 KB
testcase_27 AC 1,522 ms
12,032 KB
権限があれば一括ダウンロードができます

ソースコード

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){
    vector<int> v(4);
    v[0] = a.m1, v[1] = a.m2, v[2] = b.m1, v[3] = b.m2;
    sort(v.begin(), v.end());
    return {v[0], v[1]};
}

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