結果
| 問題 |
No.1000 Point Add and Array Add
|
| コンテスト | |
| ユーザー |
Shibuyap
|
| 提出日時 | 2020-02-28 21:37:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 233 ms / 2,000 ms |
| コード長 | 1,067 bytes |
| コンパイル時間 | 1,524 ms |
| コンパイル使用メモリ | 168,288 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-10-13 17:01:36 |
| 合計ジャッジ時間 | 4,962 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
const int MAX_N = 300005;
ll bit[MAX_N+1];
int nn = MAX_N; // 1-index
void adds(int a, ll w){
for(int x = a; x <= nn; x += x & -x) bit[x] += w;
}
ll sums(int a){ // bit[1,a]の和を返す.
ll ret = 0;
for(int x = a; x > 0; x -= x & -x) ret += bit[x];
return ret;
}
int main() {
ll n, q;
cin >> n >> q;
ll a[n + 1] = {};
srep(i,1,n+1)cin >> a[i];
char c[q];
ll x[q], y[q];
rep(i,q)cin >> c[i] >> x[i] >> y[i];
ll b[n+1] = {};
drep(i,q){
if(c[i] == 'A'){
b[x[i]] += y[i] * sums(x[i]);
}else{
adds(x[i], 1);
adds(y[i] + 1, -1);
}
}
srep(i,1,n+1){
b[i] += sums(i) * a[i];
cout << b[i] << ' ';
}
cout << endl;
return 0;
}
Shibuyap