結果

問題 No.1000 Point Add and Array Add
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-04-02 18:21:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 374 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 211,920 KB
実行使用メモリ 19,848 KB
最終ジャッジ日時 2024-04-02 18:21:20
合計ジャッジ時間 9,457 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 4 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 262 ms
18,936 KB
testcase_17 AC 218 ms
11,624 KB
testcase_18 AC 360 ms
19,848 KB
testcase_19 AC 370 ms
19,848 KB
testcase_20 AC 336 ms
19,848 KB
testcase_21 AC 356 ms
19,848 KB
testcase_22 AC 374 ms
19,848 KB
testcase_23 AC 357 ms
19,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
using ll = long long;
struct S{
	ll sum;
	ll size;
};
S op(S a, S b) {
	return {a.sum+b.sum, a.size+b.size};
}
S e() {return {0, 0};}
S mapping(ll f, S x) {return {x.sum + f, x.size};}
ll composition(ll f, ll g) {return f + g;}
ll id() {return 0;}
int main() {
	int N, Q;cin >> N >> Q;
	vector<ll> A(N + 1, 0);
	for (int i = 1;i <= N;i++) cin >> A[i];
	vector<S> B(N + 1, {0, 1});
	lazy_segtree<S, op, e, ll, mapping, composition, id> seg(B);
       vector<ll> ans(N + 1, 0);	
	while (Q--) {
		char c;cin >> c;
		if (c == 'A') {
			int x;ll y;cin >> x >> y;
			ans[x] += A[x] * seg.get(x).sum;
			seg.set(x, {0, 1});
			A[x] += y;
		} else {
			int x, y;cin >> x >> y;
			seg.apply(x, y + 1, 1);
		}
	}
	for (int i = 1;i <= N;i++) {
		ans[i] += seg.get(i).sum * A[i];
		cout << ans[i]<< " ";
	}
	cout << endl;
}
0