# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71958 | 2018-08-26T04:02:55 Z | 마릴린 희정(#2180, gs14004, ho94949) | Easy Data Structure Problem (FXCUP3_easy) | C++17 | 4 ms | 2424 KB |
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <math.h> #include <limits.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <numeric> #include <deque> #include <bitset> #include <iostream> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; struct rmq{ int tree[530000], lim; void init(int n){ memset(tree, 0x3f, sizeof(tree)); for(lim = 1; lim <= n; lim <<= 1); } void add(int x, int v){ x += lim; tree[x] = min(tree[x], v); while(x > 1){ x >>= 1; tree[x] = min(tree[2*x], tree[2*x+1]); } } int query(int s, int e){ s += lim; e += lim; int ret = 1e9; while(s < e){ if(s%2 == 1) ret = min(ret, tree[s++]); if(e%2 == 0) ret = min(ret, tree[e--]); s >>= 1; e >>= 1; } if(s == e) ret = min(ret, tree[s]); return ret; } }rmq; int n, q, a[200005]; int main(){ scanf("%d %d",&n,&q); rmq.init(n); for(int i=1; i<=n; i++){ scanf("%d",&a[i]); rmq.add(i, a[i]); } while(q--){ int l, r; scanf("%d %d",&l,&r); printf("%d\n", rmq.query(l, r)); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2424 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 2424 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |