結果

問題 No.1000 Point Add and Array Add
ユーザー square1001square1001
提出日時 2020-03-01 18:14:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 463 ms / 2,000 ms
コード長 1,008 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 15,140 KB
最終ジャッジ日時 2024-04-21 22:21:04
合計ジャッジ時間 5,748 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 301 ms
11,488 KB
testcase_17 AC 239 ms
10,888 KB
testcase_18 AC 463 ms
15,140 KB
testcase_19 AC 463 ms
15,012 KB
testcase_20 AC 325 ms
15,016 KB
testcase_21 AC 369 ms
14,884 KB
testcase_22 AC 348 ms
15,008 KB
testcase_23 AC 379 ms
15,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<string> tp(Q); vector<int> x(Q), y(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> tp[i] >> x[i] >> y[i];
		--x[i];
	}
	int B = 0;
	while (B * B < Q) ++B;
	vector<long long> ans(N);
	for (int i = 0; i < B; ++i) {
		int ql = i * Q / B, qr = (i + 1) * Q / B;
		vector<int> imos(N + 1);
		for (int j = ql; j < qr; ++j) {
			if (tp[j] == "B") {
				++imos[x[j]];
				--imos[y[j]];
				for (int k = ql; k < j; ++k) {
					if (tp[k] == "A" && x[j] <= x[k] && x[k] < y[j]) {
						ans[x[k]] += y[k];
					}
				}
			}
		}
		for (int j = 0; j < N; ++j) {
			imos[j + 1] += imos[j];
			ans[j] += A[j] * imos[j];
		}
		for (int j = ql; j < qr; ++j) {
			if (tp[j] == "A") {
				A[x[j]] += y[j];
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		if (i) cout << ' ';
		cout << ans[i];
	}
	return 0;
}
0