Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
44434 _ 课堂检测 C++ 通过 100 189 MS 1036 KB 1139 2022-02-08 16:37:21

Tests(23/23):


#include <bits/stdc++.h> using namespace std; typedef long long ll; ll read() { ll x(0); int p(1); 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 x * p; } void write(ll x) { if (x < 0) putchar('-'), x = -x; if (x >= 10) write(x / 10); putchar((x % 10) | 48); } constexpr ll MXN = 100005; constexpr ll BW = 316; ll arr[MXN], tag[BW + 5]; ll N, M; int main() { cin >> N; for (ll i(0); i != N; ++i) arr[i] = read(); cin >> M; for (ll opt, l, r, x; M--;) { cin >> opt; if (opt == 1) { cin >> l >> r >> x; --l; if (l / BW == r / BW) { for (ll i(l); i != r; ++i) { arr[i] += x; } } else { for (ll i(l); i / BW == l / BW; ++i) arr[i] += x; for (ll i(l / BW + 1); i != r / BW; ++i) tag[i] += x; for (ll i(r / BW * BW); i != r; ++i) arr[i] += x; } } else { x = read() - 1; cout << arr[x] + tag[x / BW] << endl; } } return 0; }


测评信息: