Submission #1115083

#TimeUsernameProblemLanguageResultExecution timeMemory
1115083Zero_OPFire (JOI20_ho_t5)C++14
7 / 100
121 ms11592 KiB
#include <bits/stdc++.h> using namespace std; struct segment_tree{ vector<int> st; segment_tree(int n) : st(n << 2) {} void build(int id, int l, int r, const vector<int>& S){ if(l == r) st[id] = S[l]; else{ int mid = l + r >> 1; build(id << 1, l, mid, S); build(id << 1 | 1, mid + 1, r, S); st[id] = max(st[id << 1], st[id << 1 | 1]); } } int query(int id, int l, int r, int u, int v){ if(v < l || u > r) return 0; if(u <= l && r <= v) return st[id]; int mid = l + r >> 1; return max(query(id << 1, l, mid, u, v), query(id << 1 | 1, mid + 1, r, u, v)); } }; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef LOCAL freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); #endif // LOCAL int N, Q; cin >> N >> Q; vector<int> S(N + 1); for(int i = 1; i <= N; ++i) cin >> S[i]; segment_tree st(N); st.build(1, 1, N, S); for(int i = 0; i < Q; ++i){ int t, l, r; cin >> t >> l >> r; cout << st.query(1, 1, N, l - t, l) << '\n'; } return 0; } /* */

Compilation message (stderr)

ho_t5.cpp: In member function 'void segment_tree::build(int, int, int, const std::vector<int>&)':
ho_t5.cpp:12:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |             int mid = l + r >> 1;
      |                       ~~^~~
ho_t5.cpp: In member function 'int segment_tree::query(int, int, int, int, int)':
ho_t5.cpp:22:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |         int mid = l + r >> 1;
      |                   ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...