結果
問題 | No.1000 Point Add and Array Add |
ユーザー | norioc |
提出日時 | 2020-05-07 14:12:13 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 326 ms / 2,000 ms |
コード長 | 1,339 bytes |
コンパイル時間 | 2,141 ms |
コンパイル使用メモリ | 168,232 KB |
実行使用メモリ | 44,872 KB |
最終ジャッジ日時 | 2023-09-04 07:41:05 |
合計ジャッジ時間 | 6,327 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
11,764 KB |
testcase_01 | AC | 5 ms
11,776 KB |
testcase_02 | AC | 5 ms
11,776 KB |
testcase_03 | AC | 5 ms
11,708 KB |
testcase_04 | AC | 5 ms
11,768 KB |
testcase_05 | AC | 5 ms
11,796 KB |
testcase_06 | AC | 5 ms
11,732 KB |
testcase_07 | AC | 5 ms
11,732 KB |
testcase_08 | AC | 5 ms
11,748 KB |
testcase_09 | AC | 5 ms
11,784 KB |
testcase_10 | AC | 5 ms
11,748 KB |
testcase_11 | AC | 5 ms
11,728 KB |
testcase_12 | AC | 8 ms
12,156 KB |
testcase_13 | AC | 6 ms
12,076 KB |
testcase_14 | AC | 8 ms
12,252 KB |
testcase_15 | AC | 8 ms
11,996 KB |
testcase_16 | AC | 233 ms
42,840 KB |
testcase_17 | AC | 204 ms
31,520 KB |
testcase_18 | AC | 322 ms
43,816 KB |
testcase_19 | AC | 320 ms
44,872 KB |
testcase_20 | AC | 279 ms
42,016 KB |
testcase_21 | AC | 326 ms
44,580 KB |
testcase_22 | AC | 305 ms
43,968 KB |
testcase_23 | AC | 326 ms
43,892 KB |
ソースコード
import std; const segSize = 1 << 20; int[segSize * 2] seg; void update(int l, int r, int v) { l += segSize; r += segSize; while (l < r) { if (l % 2 == 1) { seg[l] += v; l++; } l /= 2; if (r % 2 == 1) { seg[r - 1] += v; r--; } r /= 2; } } long get(int ind) { ind += segSize; int v = seg[ind]; while (true) { ind /= 2; // 上にのぼる if (ind == 0) break; v += seg[ind]; } return v; } alias Q = Tuple!(string, "c", int, "x", int, "y"); void main() { int n, q; scan(n, q); auto a = readints; Q[] qs; foreach (_; 0..q) { string c; int x, y; scan(c, x, y); qs ~= Q(c, x, y); } auto ans = new long[n + 1]; foreach_reverse (e; qs) { if (e.c == "A") { ans[e.x] += e.y * get(e.x); } if (e.c == "B") { update(e.x, e.y + 1, 1); } } foreach (i; 1..n+1) { ans[i] += a[i-1] * (get(i) + 0); } writeln(ans[1..$].map!text.join(' ')); } void scan(T...)(ref T a) { string[] ss = readln.split; foreach (i, t; T) a[i] = ss[i].to!t; } T read(T=string)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readints = reads!int;