|
| 1 | +--- |
| 2 | +data: |
| 3 | + _extendedDependsOn: |
| 4 | + - icon: ':heavy_check_mark:' |
| 5 | + path: weilycoder/data-struct/static_range_sum.hpp |
| 6 | + title: weilycoder/data-struct/static_range_sum.hpp |
| 7 | + _extendedRequiredBy: [] |
| 8 | + _extendedVerifiedWith: [] |
| 9 | + _isVerificationFailed: false |
| 10 | + _pathExtension: cpp |
| 11 | + _verificationStatusIcon: ':heavy_check_mark:' |
| 12 | + attributes: |
| 13 | + '*NOT_SPECIAL_COMMENTS*': '' |
| 14 | + PROBLEM: https://judge.yosupo.jp/problem/static_range_sum |
| 15 | + links: |
| 16 | + - https://judge.yosupo.jp/problem/static_range_sum |
| 17 | + bundledCode: "#line 1 \"test/static_range_sum.test.cpp\"\n#define PROBLEM \"https://judge.yosupo.jp/problem/static_range_sum\"\ |
| 18 | + \n\n#line 1 \"weilycoder/data-struct/static_range_sum.hpp\"\n\n\n\n#include <cstddef>\n\ |
| 19 | + #include <vector>\n\nnamespace weilycoder {\ntemplate <typename T, typename ptr_t\ |
| 20 | + \ = size_t> struct StaticRangeSum {\n std::vector<T> prefix_sum;\n\n StaticRangeSum(const\ |
| 21 | + \ std::vector<T> &data) : prefix_sum(data.size() + 1) {\n for (ptr_t i = 1;\ |
| 22 | + \ i <= data.size(); ++i)\n prefix_sum[i] = prefix_sum[i - 1] + data[i - 1];\n\ |
| 23 | + \ }\n\n T query(ptr_t l, ptr_t r) const { return prefix_sum[r] - prefix_sum[l];\ |
| 24 | + \ }\n};\n} // namespace weilycoder\n\n\n#line 4 \"test/static_range_sum.test.cpp\"\ |
| 25 | + \n#include <cstdint>\n#include <iostream>\n#line 7 \"test/static_range_sum.test.cpp\"\ |
| 26 | + \nusing namespace std;\nusing namespace weilycoder;\n\nint main() {\n cin.tie(nullptr)->sync_with_stdio(false);\n\ |
| 27 | + \ cin.exceptions(cin.failbit | cin.badbit);\n size_t n, q;\n cin >> n >> q;\n\ |
| 28 | + \n vector<uint64_t> arr(n);\n for (size_t i = 0; i < n; ++i)\n cin >> arr[i];\n\ |
| 29 | + \n StaticRangeSum<uint64_t> sum(arr);\n while (q--) {\n size_t l, r;\n \ |
| 30 | + \ cin >> l >> r;\n cout << sum.query(l, r) << '\\n';\n }\n return 0;\n}\n" |
| 31 | + code: "#define PROBLEM \"https://judge.yosupo.jp/problem/static_range_sum\"\n\n\ |
| 32 | + #include \"../weilycoder/data-struct/static_range_sum.hpp\"\n#include <cstdint>\n\ |
| 33 | + #include <iostream>\n#include <vector>\nusing namespace std;\nusing namespace\ |
| 34 | + \ weilycoder;\n\nint main() {\n cin.tie(nullptr)->sync_with_stdio(false);\n \ |
| 35 | + \ cin.exceptions(cin.failbit | cin.badbit);\n size_t n, q;\n cin >> n >> q;\n\ |
| 36 | + \n vector<uint64_t> arr(n);\n for (size_t i = 0; i < n; ++i)\n cin >> arr[i];\n\ |
| 37 | + \n StaticRangeSum<uint64_t> sum(arr);\n while (q--) {\n size_t l, r;\n \ |
| 38 | + \ cin >> l >> r;\n cout << sum.query(l, r) << '\\n';\n }\n return 0;\n}" |
| 39 | + dependsOn: |
| 40 | + - weilycoder/data-struct/static_range_sum.hpp |
| 41 | + isVerificationFile: true |
| 42 | + path: test/static_range_sum.test.cpp |
| 43 | + requiredBy: [] |
| 44 | + timestamp: '2025-10-28 23:07:26+08:00' |
| 45 | + verificationStatus: TEST_ACCEPTED |
| 46 | + verifiedWith: [] |
| 47 | +documentation_of: test/static_range_sum.test.cpp |
| 48 | +layout: document |
| 49 | +redirect_from: |
| 50 | +- /verify/test/static_range_sum.test.cpp |
| 51 | +- /verify/test/static_range_sum.test.cpp.html |
| 52 | +title: test/static_range_sum.test.cpp |
| 53 | +--- |
0 commit comments