結果

問題 No.1441 MErGe
ユーザー tempura_pptempura_pp
提出日時 2021-03-26 23:26:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,532 bytes
コンパイル時間 3,703 ms
コンパイル使用メモリ 183,676 KB
実行使用メモリ 18,820 KB
最終ジャッジ日時 2023-08-19 10:16:23
合計ジャッジ時間 16,979 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 WA -
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 408 ms
18,604 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<atcoder/all>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

struct S {
    int num;
    ll sum;
};

struct F {
    int num;
    ll sum;
};

S op(S l, S r) { return S{l.num + r.num, l.sum + r.sum}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return l.num == -1 ? r : S{l.num, l.sum}; }

F composition(F l, F r) { return l; }

F id() { return F{-1, 0}; }

int k;
bool g(S a){
    return a.num <=k;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin>>n>>q;
    vector<S> vs(n);
    rep(i,n){
        int x;
        cin>>x;
        vs[i] = {1, x};
    }
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(vs);

    while(q--){
        int t, l, r;
        cin>>t>>l>>r;
        --l;
        k = l;
        int l2 = seg.max_right<g>(0);
        k = r;
        int r2 = seg.max_right<g>(0);
        if(t == 1){
            ll sum = seg.prod(l2, r2).sum;
            seg.apply(l2, r2, {0, 0});
            seg.apply(r2-1, r2, {1, sum});
        } else {
            cout<<seg.prod(l2, r2).sum<<endl;
        }
    }
}
0