結果

問題 No.3265 地元に帰れば天才扱い!
ユーザー のらら
提出日時 2025-08-11 16:26:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 3,239 ms
コンパイル使用メモリ 173,760 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-06 12:32:16
合計ジャッジ時間 10,962 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other RE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

//TLE解
#include <iostream>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
//#define endl "\n";
ll N, A[200009], Q, X, Y, L, R;
ll l, r, deg[200009];

int main(){
  cin >> N;
  for(int i = 1; i <= N; i++) cin >> A[i];
  cin >> Q;
  l = N, r = 1;
  for(int q = 1; q <= Q; q++){
    cin >> X >> Y >> L >> R;
    A[X] = Y;
    deg[L]++;
    deg[R + 1]--;
    l = min(l, L);
    r = max(r, R);
    ll cnt = 0;
    for(int i = 1; i < l; i++) cnt += deg[i];
    ll ans = 0;
    for(int i = l; i <= r; i++){
      cnt += deg[i];
      ans += A[i] * cnt;
    }
    cout << ans << endl;
  }
  return 0;
}
0