Submission #493246

#TimeUsernameProblemLanguageResultExecution timeMemory
493246PiejanVDCIndex (COCI21_index)C++17
20 / 110
2574 ms1620 KiB
#include <bits/stdc++.h> using namespace std; signed main() { int n,_q; cin>>n>>_q; vector<int>v(n); for(auto &z : v) cin>>z; while(_q--) { int l,r; cin>>l>>r; l--,r--; vector<int>nw; for(int ll = l ; ll <= r ; ll++) { nw.push_back(v[ll]); } sort(nw.rbegin(),nw.rend()); int len = r-l+1; int ans=0; for(int i = len-1 ; i >= 0 ; i--) { int curr = min(i+1,nw[i]); ans=max(ans,curr); } cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...