結果

問題 No.2433 Min Increasing Sequence
ユーザー momoyuumomoyuu
提出日時 2023-08-18 22:33:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 1,548 bytes
コンパイル時間 4,066 ms
コンパイル使用メモリ 265,696 KB
実行使用メモリ 16,844 KB
最終ジャッジ日時 2023-08-18 22:34:12
合計ジャッジ時間 9,812 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 324 ms
16,720 KB
testcase_05 AC 133 ms
9,832 KB
testcase_06 AC 216 ms
16,272 KB
testcase_07 AC 116 ms
9,884 KB
testcase_08 AC 239 ms
16,524 KB
testcase_09 AC 191 ms
15,936 KB
testcase_10 AC 111 ms
9,400 KB
testcase_11 AC 159 ms
10,168 KB
testcase_12 AC 83 ms
6,440 KB
testcase_13 AC 89 ms
6,520 KB
testcase_14 AC 186 ms
10,092 KB
testcase_15 AC 67 ms
6,464 KB
testcase_16 AC 88 ms
6,608 KB
testcase_17 AC 62 ms
6,396 KB
testcase_18 AC 295 ms
16,600 KB
testcase_19 AC 327 ms
16,600 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 286 ms
16,340 KB
testcase_22 AC 315 ms
16,544 KB
testcase_23 AC 250 ms
16,184 KB
testcase_24 AC 321 ms
16,844 KB
testcase_25 AC 271 ms
16,224 KB
testcase_26 AC 210 ms
15,904 KB
testcase_27 AC 255 ms
16,300 KB
testcase_28 AC 256 ms
15,972 KB
testcase_29 AC 38 ms
4,696 KB
testcase_30 AC 35 ms
4,788 KB
testcase_31 AC 26 ms
4,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;


#include<atcoder/modint>
#include<atcoder/lazysegtree>
#include<atcoder/segtree>
using mint = atcoder::modint998244353;

int op1(int a,int b){
    return max(a,b);
}
int e1(){
    return -1;
}
int op2(int a,int b){
    return min(a,b);
}
int e2(){
    return 1e9;
}

using dat = pair<mint,mint>;
dat op(dat a,dat b){
    a.first += b.first;
    a.second += b.second;
    return a;
}
dat e(){
    return make_pair(0,0);
}
mint composition(mint a,mint b){
    return a + b;
}
mint id(){
    return 0;}

dat mapping(mint a,dat b){
    b.first += a*b.second;
    return b;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i = 0;i<n;i++) cin>>a[i];
    atcoder::segtree<int,op1,e1> s1(n+1);
    atcoder::lazy_segtree<dat,op,e,mint,mapping,composition,id> seg(n+1);
    atcoder::segtree<int,op2,e2> s2(n+1);
    for(int i = 0;i<=n;i++) seg.set(i,make_pair(0,1));
    seg.apply(0,1,1);
    
    vector<pair<int,int>> now;
    for(int i = 0;i<n;i++) now.push_back(make_pair(a[i],i));
    sort(now.begin(),now.end());
    for(int i = 0;i<n;i++){
        int ni = now[i].second;
        int le = 0;
        if(ni>0) le = s1.prod(0,ni) + 1;
        s1.set(ni,ni);
        mint can = seg.prod(le,ni+1).first;
        int ri = s2.prod(ni+1,n+1);
        if(ri==1e9) ri = n;
        seg.apply(ni,ri+1,can);
        s2.set(ni,ni);
        //cout<<can.val()<<endl;
    }
    cout<<seg.get(n).first.val()<<endl;


}

0