Submit Info #12760

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

ケース詳細
Name Status Time Memory
example_00 AC 4 ms 0.68 MiB
max_random_00 AC 8846 ms 3.11 MiB
max_random_01 AC 8812 ms 3.05 MiB
max_random_02 AC 8826 ms 3.05 MiB
medium_00 AC 2 ms 0.72 MiB
medium_01 AC 3 ms 0.72 MiB
medium_02 AC 3 ms 0.68 MiB
random_00 AC 4182 ms 2.26 MiB
random_01 AC 4944 ms 2.43 MiB
random_02 AC 1432 ms 1.61 MiB
small_00 AC 2 ms 0.67 MiB
small_01 AC 2 ms 0.67 MiB
small_02 AC 2 ms 0.67 MiB
small_03 AC 1 ms 0.71 MiB
small_04 AC 1 ms 0.68 MiB
small_05 AC 2 ms 0.67 MiB
small_06 AC 1 ms 0.68 MiB
small_07 AC 4 ms 0.67 MiB
small_08 AC 1 ms 0.68 MiB
small_09 AC 2 ms 0.72 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; ll x[N]; 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); cin >> n >> q; for (int i = 1; i <= n; i++) { cin >> x[i]; } while (q--) { int t, l, r; cin >> t >> l >> r; l++; if (t == 0) { ll y; cin >> y; mn(l, r, y); } if (t == 1) { ll y; cin >> y; mx(l, r, y); } if (t == 2) { ll y; cin >> y; add(l, r, y); } if (t == 3) { cout << sum(l, r) << "\n"; } } return 0; }