結果
問題 | No.789 範囲の合計 |
ユーザー | pekempey |
提出日時 | 2019-02-21 08:04:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 808 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 54,272 KB |
実行使用メモリ | 93,056 KB |
最終ジャッジ日時 | 2024-04-27 22:33:37 |
合計ジャッジ時間 | 11,002 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | TLE | - |
testcase_03 | AC | 60 ms
6,940 KB |
testcase_04 | TLE | - |
testcase_05 | AC | 723 ms
80,768 KB |
testcase_06 | AC | 882 ms
82,816 KB |
testcase_07 | AC | 46 ms
6,940 KB |
testcase_08 | AC | 662 ms
65,792 KB |
testcase_09 | AC | 561 ms
60,032 KB |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
ソースコード
#include <stdio.h> #include <map> #define Z (1 << 30) std::map<int, long long> S; void update(int k, int v) { k += Z; for (int i = 0; i <= 30; i++) S[k >> i] += v; } long long query(int l, int r) { l += Z; r += Z; long long o = 0; while (l <= r) { if ((l & 1) == 1) o += S[l++]; if ((r & 1) == 0) o += S[r--]; l >>= 1; r >>= 1; } return o; } int main() { int N; scanf("%d", &N); long long ans = 0; while (N--) { int t; scanf("%d", &t); if (t == 0) { int x, y; scanf("%d %d", &x, &y); update(x, y); } else { int l, r; scanf("%d %d", &l, &r); ans += query(l, r); } } printf("%lld\n", ans); return 0; }