# Submit Info #3606

Problem Lang User Status Time Memory
Point Add Range Sum cpp mdstoy WA 256 ms 10.05 MiB

ケース詳細
Name Status Time Memory
example_00 WA 1 ms 0.67 MiB
max_random_00 WA 240 ms 9.96 MiB
max_random_01 WA 248 ms 10.01 MiB
max_random_02 WA 245 ms 9.76 MiB
max_random_03 WA 256 ms 10.05 MiB
max_random_04 WA 252 ms 10.01 MiB
random_00 WA 201 ms 8.93 MiB
random_01 WA 215 ms 9.28 MiB
random_02 WA 136 ms 3.96 MiB
random_03 WA 57 ms 7.93 MiB
random_04 WA 72 ms 6.74 MiB
small_00 WA 1 ms 0.72 MiB
small_01 WA 2 ms 0.68 MiB
small_02 WA 5 ms 0.73 MiB
small_03 WA 2 ms 0.67 MiB
small_04 WA 5 ms 0.71 MiB
small_05 WA 2 ms 0.73 MiB
small_06 WA 2 ms 0.67 MiB
small_07 WA 3 ms 0.72 MiB
small_08 WA 2 ms 0.68 MiB
small_09 WA 1 ms 0.67 MiB

#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define FORR(i, m, n) for (int i = (m); i >= (n); i--) #define REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n) - 1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define REPS(c, s) for (char c : s) #define ALL(c) (c).begin(), (c).end() #define SORT(c) sort(ALL(c)) #define REV(c) reverse(ALL(c)) #define sz(v) (int)v.size() #define endl '\n' template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} const int MOD = 1000000007; const int INF = 1000000001; const ll LINF = 1000000001000000001LL; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(numeric_limits<double>::max_digits10); solve(); return 0; } class SegmentTree { int n; vector<int> node; public: SegmentTree(vector<int> v) { n = 1; int s = v.size(); while (n < s) n *= 2; node.resize(2 * n - 1, INF); for (int i = 0; i < s; i++) node[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]); } void update(int x, int val) { x += (n - 1); node[x] = val; while(x > 0) { x = (x - 1) / 2; node[x] = min(node[2 * x + 1], node[2 * x + 2]); } } int find(int a, int b, int k = 0, int l = 0, int r = -1) { if(r < 0) r = n; if(r <= a || b <= l) return INF; if(a <= l && r <= b) return node[k]; int vl = find(a, b, 2 * k + 1, l, (l + r) / 2); int vr = find(a, b, 2 * k + 2, (l + r) / 2, r); return min(vl, vr); } }; void solve() { int n, q; cin >> n >> q; vector<int> a(n); REP(i, n) cin >> a[i]; SegmentTree st(a); REP(i, q) { int l, r; cin >> l >> r; cout << st.find(l, r) << endl; } }