提交时间:2022-02-08 16:18:51
运行 ID: 44429
#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(long long 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; long long 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; }