結果

問題 No.3265 地元に帰れば天才扱い!
ユーザー DeltaStruct
提出日時 2025-03-02 17:14:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 754 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 198,612 KB
実行使用メモリ 11,132 KB
最終ジャッジ日時 2025-09-06 12:30:35
合計ジャッジ時間 9,852 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3 RE * 1
other RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int n; cin >> n;
  vector<int> A(n),segtree0(2*n),segtree1(2*n); for (int& a:A) cin >> a;
  copy(A.begin(),A.end(),segtree1.begin()+n); __int128_t res = 0,mx = 1;
  for (int i(0);i < 17;++i) mx *= 10;
  for (int i(n-1);i;--i) segtree1[i] = segtree1[i<<1]+segtree1[i<<1|1];
  int q; cin >> q;
  while(q--){
    int a,b,c,d; cin >> a >> b >> c >> d; --a,--c;
    for (int l(n+a);l;l>>=1) res += (b-A[a])*segtree0[l],segtree1[l] += b-A[a];
    for (int l(n+c),r(n+d);l < r;l>>=1,r>>=1){
      if (l&1) res += segtree1[l],++segtree0[l++];
      if (r&1) res += segtree1[--r],++segtree0[r];
    }
    A[a] = b;
    cout << (long long)res << endl;
    assert(res<=mx);
  }
}
0