結果

問題 No.1000 Point Add and Array Add
ユーザー chocopuuchocopuu
提出日時 2020-02-28 22:34:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 559 ms / 2,000 ms
コード長 1,838 bytes
コンパイル時間 2,896 ms
コンパイル使用メモリ 204,716 KB
実行使用メモリ 33,168 KB
最終ジャッジ日時 2023-08-03 21:15:57
合計ジャッジ時間 8,225 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 276 ms
20,468 KB
testcase_17 AC 257 ms
16,128 KB
testcase_18 AC 411 ms
25,624 KB
testcase_19 AC 417 ms
25,544 KB
testcase_20 AC 260 ms
20,792 KB
testcase_21 AC 559 ms
33,168 KB
testcase_22 AC 320 ms
22,484 KB
testcase_23 AC 539 ms
32,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#include"ext/pb_ds/assoc_container.hpp"
#include"ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
template<typename T>
using pbds = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

/*
insert(logN)
erase(logN)
find_by_order(logN)//k番目の要素のイテレータを返す
order_of_key(logN)//k以上で最初の数が何番目かを返す
(K未満の個数が何個あるかが分かるらしい)
gp_hash_table<int,int>m//高速なmap
*/
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr int INF = 1e18;
 
signed main(){
	int N,Q;
	cin >> N >> Q;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	pbds<int>st;
	vector<vector<int>>event(N+1);
	vector<vector<pair<int,int>>>point(N);
	REP(i,Q){
		char c;
		int X,Y;
		cin >> c >> X >> Y;
		--X;
		if(c == 'B'){
			--Y;
			event[X].emplace_back(i);
			event[Y + 1].emplace_back(Q + i);
		}else{
			point[X].emplace_back(Y,i);
		}
	}
	vector<int>b(N);
	REP(i,N){
		for(auto e:event[i]){
			if(e < Q){
				st.insert(e);
			}else{
				st.erase(e - Q);
			}
		}
		b[i] += a[i] * st.size();
		for(auto e:point[i]){
			int t = st.order_of_key(e.second);
			b[i] += (st.size() - t) * e.first;
		}
	}
	REP(i,b.size())cout << b[i] << " \n"[i+1 == b.size()];
}
0