# Submit Info #12779

Problem Lang User Status Time Memory
Range Chmin Chmax Add Range Sum cpp BlueDiamond AC 5754 ms 3.11 MiB

ケース詳細
Name Status Time Memory
example_00 AC 2 ms 2.16 MiB
max_random_00 AC 5754 ms 3.11 MiB
max_random_01 AC 5742 ms 3.05 MiB
max_random_02 AC 5720 ms 3.11 MiB
medium_00 AC 4 ms 2.17 MiB
medium_01 AC 3 ms 2.23 MiB
medium_02 AC 4 ms 2.17 MiB
random_00 AC 2724 ms 2.87 MiB
random_01 AC 3175 ms 2.78 MiB
random_02 AC 923 ms 2.67 MiB
small_00 AC 2 ms 2.17 MiB
small_01 AC 3 ms 2.17 MiB
small_02 AC 2 ms 2.17 MiB
small_03 AC 3 ms 2.21 MiB
small_04 AC 3 ms 2.17 MiB
small_05 AC 0 ms 2.16 MiB
small_06 AC 0 ms 2.24 MiB
small_07 AC 0 ms 2.18 MiB
small_08 AC 3 ms 2.24 MiB
small_09 AC 3 ms 2.17 MiB

#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); typedef long long ll; typedef long double ld; const int N = 200000 + 7; int n, q; struct Brute { private: ll x[N]; public: void init() { for (int i = 0; i < N; i++) { x[i] = 0LL; } } void mn(int l, int r, ll y) { for (int i = l; i <= r; i++) { x[i] = min(x[i], y); } } void mx(int l, int r, ll y) { for (int i = l; i <= r; i++) { x[i] = max(x[i], y); } } void add(int l, int r, ll y) { for (int i = l; i <= r; i++) { x[i] += y; } } ll sum(int l, int r) { ll sol = 0; for (int i = l; i <= r; i++) { sol += x[i]; } return sol; } }; int main() { ios::sync_with_stdio(false); cin.tie(0); Brute br; br.init(); cin >> n >> q; for (int i = 1; i <= n; i++) { ll x; cin >> x; br.add(i, i, x); } while (q--) { int t, l, r; cin >> t >> l >> r; l++; if (t == 0) { ll y; cin >> y; br.mn(l, r, y); } if (t == 1) { ll y; cin >> y; br.mx(l, r, y); } if (t == 2) { ll y; cin >> y; br.add(l, r, y); } if (t == 3) { cout << br.sum(l, r) << "\n"; } } return 0; }