Submission #71957

#TimeUsernameProblemLanguageResultExecution timeMemory
71957비타500 (#118)Easy Data Structure Problem (FXCUP3_easy)C++17
0 / 100
3 ms376 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; template<class T> struct SegmentTree { int n; vector<T> V; SegmentTree(int n) : n(n) { V = vector<T>(4*n); } void update(int h, int tl, int tr, int p, T x) { if(tr < p || tl > p) return; if(tl == tr) { V[h] = x; // STUFF return; } int mid = (tl + tr) >> 1; update(h*2, tl, mid, p, x); update(h*2+1, mid+1, tr, p, x); V[h]=min(V[h*2],V[h*2+1]); } void update(int p, T x) { update(1, 1, n, p, x); } T query(int h, int tl, int tr, int l, int r) { if(tr < l || tl > r) return (int)1e9; // STUFF if(l <= tl && tr <= r) return V[h]; int mid = (tl + tr) >> 1; T ql = query(h*2, tl, mid, l, r); T qr = query(h*2+1, mid+1, tr, l, r); return min(ql,qr); // STUFF } T query(int l, int r) { return query(1, 1, n, l, r); } }; int main() { int n,q,l,r; scanf("%d%d",&n,&q); SegmentTree<int> st(n+1); for(int i=1; i<=n; i++) { int x; scanf("%d", &x); st.update(i,x); } while(q--) { scanf("%d%d",&l,&r); printf("%d\n",st.query(l,r)); } return 0; }

Compilation message (stderr)

easy.cpp: In function 'int main()':
easy.cpp:40: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:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
easy.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&l,&r);
   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...