Submission #71958

#TimeUsernameProblemLanguageResultExecution timeMemory
71958마릴린 희정 (#118)Easy Data Structure Problem (FXCUP3_easy)C++17
0 / 100
4 ms2424 KiB
#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 (stderr)

easy.cpp: In function 'int main()':
easy.cpp:55:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&q);
  ~~~~~^~~~~~~~~~~~~~~
easy.cpp:58:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
easy.cpp:61:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  while(q--){ int l, r; scanf("%d %d",&l,&r);
                        ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...