結果
| 問題 |
No.1000 Point Add and Array Add
|
| コンテスト | |
| ユーザー |
chocopuu
|
| 提出日時 | 2020-02-28 22:34:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 581 ms / 2,000 ms |
| コード長 | 1,838 bytes |
| コンパイル時間 | 4,323 ms |
| コンパイル使用メモリ | 206,760 KB |
| 実行使用メモリ | 33,408 KB |
| 最終ジャッジ日時 | 2024-10-13 18:23:42 |
| 合計ジャッジ時間 | 8,940 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#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()];
}
chocopuu