結果
| 問題 | No.1000 Point Add and Array Add |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-01 23:44:46 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 123 ms / 2,000 ms |
| + 3µs | |
| コード長 | 1,477 bytes |
| 記録 | |
| コンパイル時間 | 7,681 ms |
| コンパイル使用メモリ | 396,448 KB |
| 実行使用メモリ | 20,064 KB |
| 最終ジャッジ日時 | 2026-10-01 23:45:05 |
| 合計ジャッジ時間 | 12,817 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
using namespace std;
using namespace atcoder;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using pll=pair<ll,ll>;
// using mint=modint;
// template<class K,class V>
// using ordered_map=tree<K,V,less<K>,rb_tree_tag,tree_order_statistics_node_update>;
struct S{
ll sum=0,len=1;
};
S op(S a,S b){
return {a.sum+b.sum,a.len+b.len};
}
S e(){
return {0,0};
}
using F=ll;
S mapping(F f,S x){
return {x.sum+f*x.len,x.len};
}
F composition(F f,F g){
return f+g;
}
F id(){
return 0;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N,Q;
cin>>N>>Q;
vll a(N),b(N,0);
rep(i,0,N){
cin>>a[i];
}
vector<S>init(N);
lazy_segtree<S,op,e,F,mapping,composition,id> seg(init);
while(Q--){
string c;
ll x,y;
cin>>c>>x>>y;
--x;
if(c=="A"){
ll cnt=seg.get(x).sum;
b[x]+=a[x]*cnt;
seg.set(x,{0,1});
a[x]+=y;
}else{
seg.apply(x,y,1);
}
}
rep(x,0,N){
ll cnt=seg.get(x).sum;
b[x]+=a[x]*cnt;
}
rep(i,0,N){
if(i)cout<<' ';
cout<<b[i];
}
cout<<endl;
}
C