結果

問題 No.1000 Point Add and Array Add
ユーザー okok
提出日時 2020-02-28 23:20:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 1,281 bytes
コンパイル時間 1,139 ms
コンパイル使用メモリ 87,652 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-21 20:47:36
合計ジャッジ時間 5,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 209 ms
7,168 KB
testcase_17 AC 160 ms
5,632 KB
testcase_18 AC 313 ms
7,936 KB
testcase_19 AC 316 ms
7,936 KB
testcase_20 AC 251 ms
7,936 KB
testcase_21 AC 259 ms
7,936 KB
testcase_22 AC 267 ms
7,936 KB
testcase_23 AC 266 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, Q, q;;
	vector<int> A, B, con;
	vector<pair<int,int>> p;
	
	cin>>N>>Q;
	
	A.resize(N);
	B.resize(N);
	con.resize(N+1);
	
	q = 1 + (int)sqrt(Q);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int i = 0, b = 0; i < Q; i++){
		char c;
		int x, y;
		
		cin>>c>>x>>y;
		
		
		if(c == 'A') {
			
			x--;
			p.push_back({x, y});
			
		} else {
			x--;
			y--;
			
			con[x]++;
			con[y+1]--;
			
			for(int j = 0; j < p.size(); j++){
				if(x <= p[j].first && p[j].first  <= y) {
					B[p[j].first] += p[j].second;
				}
			}
		}
		
		if(i%q == 0 || i + 1 == Q) {
			for(int i = 0; i < N; i++){
				con[i+1] += con[i];
			}
			
			for(int i = 0; i < N; i++){
				B[i] += A[i] * con[i];
				con[i] = 0;
			}
			con[N] = 0;
			
			for(int j = 0; j < p.size(); j++){
				A[p[j].first] += p[j].second;
			}
			p.clear();
		}
	}
	
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<B[i];
	}
	cout<<endl;
	
	return 0;
}
0