Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
44428 | _ | 课堂检测 | C++ | 解答错误 | 34 | 5 MS | 644 KB | 1140 | 2022-02-08 16:18:13 |
#include <bits/stdc++.h> using namespace std; int read() { int x(0); bool p(true); char c(getchar()); while (c < '0' || c > '9') (c ^ '-' ? 0 : p = !p), c = getchar(); while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return p ? x : -x; } void write(int x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) write(x / 10); putchar((x % 10) | 48); } constexpr int MXN = 100005; constexpr int BW = 316; int arr[MXN], tag[BW + 5]; int N; int main() { N = read(); for (int i(0); i != N; ++i) arr[i] = read(); N = read(); for (int opt, l, r, x; N--;) { opt = read(); if (opt == 1) { l = read() - 1, r = read(), x = read(); if (l / BW == r / BW) { for (int i(l); i != r; ++i) { arr[i] += x; } } else { for (int i(l); i % BW; ++i) arr[i] += x; for (int i(l / BW + 1); i != r / BW; ++i) tag[i] += x; for (int i(r / BW * BW); i != r; ++i) arr[i] += x; } } else { x = read() - 1; write(arr[x] + tag[x / BW]), putchar('\n'); } } return 0; }