結果
問題 | No.1000 Point Add and Array Add |
ユーザー |
|
提出日時 | 2023-02-15 04:00:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 277 ms / 2,000 ms |
コード長 | 1,127 bytes |
コンパイル時間 | 2,161 ms |
コンパイル使用メモリ | 196,260 KB |
最終ジャッジ日時 | 2025-02-10 15:35:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back using vi = vector <int>; using ll = long long; using vl = vector <ll>; using pii = pair <int, int>; const ll mod = 998244353; //~ const ll mod = 1e9 + 7; ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a; for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; } const int N = 2e5 + 11; const int B = 500; ll a[N]; ll diff[N], cnt[N], b[N]; int main() { ios::sync_with_stdio(0); int n, q; cin >> n >> q; for(int i = 1; i <= n; i ++) { cin >> a[i]; } vector <pii> add; for(int t = 1; t <= q; t ++) { char c; int x, y; cin >> c >> x >> y; if(c == 'A') { add.pb({x, y}); } else { for(auto [i, j] : add) if(i >= x && i <= y) { b[i] += j; } cnt[x] ++; cnt[y + 1] --; } if(t % B == 0 || t == q) { int c = 0; for(int i = 1; i <= n; i ++) { c += cnt[i]; b[i] += c * a[i]; } fill(cnt, cnt + n + 1, 0); for(auto [i, j] : add) a[i] += j; add.clear(); } } for(int i = 1; i <= n; i ++) cout << b[i] << ' '; cout << '\n'; }