結果

問題 No.877 Range ReLU Query
ユーザー cho435cho435
提出日時 2023-04-22 16:05:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 2,639 ms
コンパイル使用メモリ 209,260 KB
実行使用メモリ 19,912 KB
最終ジャッジ日時 2024-04-24 19:35:06
合計ジャッジ時間 7,606 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)

struct S{
  ll val;
  int sz;
};
S op(S a,S b){
  return {a.val+b.val,a.sz+b.sz};
}
S e(){
  return {0,0};
}

int main(){
  int n,q;
  cin>>n>>q;
  vector<vector<int>> p(n+q);
  rep(i,n){
    int a;
    cin>>a;
    p.at(i)={a,2,i};
  }
  rep(i,q){
    int t,l,r,x;
    cin>>t>>l>>r>>x;
    l--;
    p.at(n+i)={x,t,l,r,i};
  }
  sort(p.begin(),p.end(),greater<vector<int>>());
  atcoder::segtree<S,op,e> seg(n);
  vector<int> ans(q);
  for(auto &v:p){
    if(v.at(1)==1){
      S s=seg.prod(v.at(2),v.at(3));
      ans.at(v.at(4))=s.val-s.sz*v.at(0);
    }else{
      seg.set(v.at(2),{v.at(0),1});
    }
  }
  rep(i,q) cout<<ans.at(i)<<'\n';
}
0