Submission #894377

#TimeUsernameProblemLanguageResultExecution timeMemory
894377vjudge1Index (COCI21_index)C++17
20 / 110
2543 ms1100 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; #define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define russian setlocale(LC_ALL,"Russian_Russia.20866"); #define file freopen("condense2.in", "r", stdin), freopen("condense2.out", "w", stdout); #define ll long long #define ull unsigned long long #define ld long double #define pll pair<ll, ll> #define pii pair<int, int> #define pli pair<ll, int> #define all(s) s.begin(), s.end() #define pb push_back #define ins insert #define mp make_pair #define sz(x) x.size() #define F first #define S second #define lb lower_bound #define ub upper_bound #define mem(x) memset(x, 0, sizeof(x)) const ll N = 200010; const ll M = 1e9 + 7; const ll block = 316; const ll mod = 1e9 + 7; const ll P = 263; const ld pi = acos(-1); const ll inf = 9e18; ll add(ll a, ll b) { if(a + b < 0) return a + b + mod; if(a + b >= mod) return a + b - mod; return a + b; } ll sub(ll a, ll b) { return (a - b + mod) % mod; } ll mul(ll a, ll b) { return a * b % mod; } ll binpow(ll a, ll n) { ll res = 1; while(n) { if(n & 1) res = mul(res, a); a = mul(a, a); n >>= 1; } return res; } ll inv(ll x) { return binpow(x, mod - 2); } ll n, q; ll p[N]; void solve() { cin >> n >> q; for(ll i = 1; i <= n; i++) cin >> p[i]; while(q--) { ll l, r; cin >> l >> r; ll lo = 0, hi = N + 10; while(hi > lo + 1) { ll mid = (lo + hi) / 2; ll cnt = 0; for(ll i = l; i <= r; i++) { if(p[i] >= mid) cnt++; } if(cnt >= mid) lo = mid; else hi = mid; } cout << lo << '\n'; } } signed main() { speed; //file; int test = 1; //cin >> test; while(test--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...