Submission #942551

#TimeUsernameProblemLanguageResultExecution timeMemory
942551vjudge1Index (COCI21_index)C++17
20 / 110
2547 ms2400 KiB
#include <bits/stdc++.h> using namespace std; using ld = long double; using ll = long long; #define int ll #define sz(x) (int)x.size() signed main(){ int n, q; cin >> n >> q; vector<int> p(n); for(auto &i : p){ cin >> i; } while(q--){ int l, r; cin >> l >> r; l--, r--; vector<int> tmp; for(int i=l; i<=r; ++i){ tmp.push_back(p[i]); } sort(tmp.rbegin(), tmp.rend()); assert(sz(tmp) == r-l+1); int low = 1, high = r - l + 1; int res = 1; while(low <= high){ int mid = (low + high) / 2; if(tmp[mid-1] >= mid){ res = mid; low = mid+1; } else { high = mid-1; } } cout << res << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...