Submission #13306


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int SZ = 1000001;
int64 d[SZ];
void add(int k, int64 x)
{
for(++k; k < SZ; k += k & -k) d[k] += x;
}
int64 sum(int k)
{
int64 ret = 0;
for(++k; k > 0; k -= k & -k) ret += d[k];
return (ret);
}
int main()
{
int N, Q;
scanf("%d %d", &N, &Q);
while(Q--) {
int S, A, B;
scanf("%d %d %d", &S, &A, &B);
if(S == 0) add(--A, B);
else printf("%lld\n", sum(--B) - sum(A - 2));
}
}

ステータス

項目 データ
問題 0649 - 区間和(セグ木、BIT練習)
ユーザー名 ei1333
投稿日時 2017-03-05 01:27:04
言語 C++11
状態 Accepted
得点 5
ソースコード長 519 Byte
最大実行時間 231 ms
最大メモリ使用量 96316 KB

セット

セット 得点 Cases
1 ALL 5 / 5 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input100-1 AC 32 ms 4960 KB
1
input100-2 AC 50 ms 6060 KB
1
input100-3 AC 86 ms 8308 KB
1
input100-4 AC 147 ms 12992 KB
1
input100-5 AC 231 ms 20112 KB
1
input1000-1 AC 81 ms 22236 KB
1
input1000-2 AC 160 ms 27304 KB
1
input1000-3 AC 91 ms 29552 KB
1
input1000-4 AC 199 ms 35896 KB
1
input1000-5 AC 75 ms 37764 KB
1
input10000-1 AC 185 ms 43600 KB
1
input10000-2 AC 197 ms 49884 KB
1
input10000-3 AC 166 ms 54632 KB
1
input10000-4 AC 179 ms 60272 KB
1
input10000-5 AC 100 ms 63100 KB
1
input100000-1 AC 208 ms 70148 KB
1
input100000-2 AC 51 ms 71124 KB
1
input100000-3 AC 49 ms 72100 KB
1
input100000-4 AC 114 ms 75512 KB
1
input100000-5 AC 183 ms 81220 KB
1
input1000000-1 AC 42 ms 84752 KB
1
input1000000-2 AC 103 ms 86908 KB
1
input1000000-3 AC 106 ms 89320 KB
1
input1000000-4 AC 188 ms 94164 KB
1
input1000000-5 AC 96 ms 96316 KB
1
input1001000-1 AC 16 ms 92712 KB
1
input1001000-2 AC 15 ms 92660 KB
1
input1001000-3 AC 17 ms 92732 KB
1
input1001000-4 AC 20 ms 92684 KB
1
input1001000-5 AC 18 ms 92760 KB
1