結果

問題 No.1000 Point Add and Array Add
ユーザー rabimearabimea
提出日時 2023-02-15 04:00:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 1,127 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 202,272 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2023-09-24 14:18:35
合計ジャッジ時間 7,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,400 KB
testcase_01 AC 2 ms
5,428 KB
testcase_02 AC 2 ms
5,420 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 2 ms
5,580 KB
testcase_05 AC 2 ms
5,428 KB
testcase_06 AC 1 ms
5,428 KB
testcase_07 AC 2 ms
5,424 KB
testcase_08 AC 2 ms
5,432 KB
testcase_09 AC 2 ms
5,416 KB
testcase_10 AC 2 ms
5,432 KB
testcase_11 AC 2 ms
5,484 KB
testcase_12 AC 3 ms
5,408 KB
testcase_13 AC 2 ms
5,424 KB
testcase_14 AC 4 ms
5,672 KB
testcase_15 AC 3 ms
5,452 KB
testcase_16 AC 172 ms
9,240 KB
testcase_17 AC 141 ms
8,764 KB
testcase_18 AC 268 ms
9,720 KB
testcase_19 AC 267 ms
9,620 KB
testcase_20 AC 201 ms
8,656 KB
testcase_21 AC 207 ms
9,844 KB
testcase_22 AC 215 ms
9,792 KB
testcase_23 AC 214 ms
9,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}

0