| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1172286 | lopkus | Index (COCI21_index) | C++20 | 2595 ms | 832 KiB |
#include <bits/stdc++.h>
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, q;
std::cin >> n >> q;
std::vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
std::cin >> a[i];
}
while(q--) {
int l, r;
std::cin >> l >> r;
std::vector<int> b = a;
sort(b.begin() + l, b.begin() + r + 1);
int L = l, R = r, ans = - 1;
while(L <= R) {
int mid = (L + R) / 2;
if(b[mid] > r - mid) {
ans = r - mid + 1;
R = mid - 1;
}
else {
L = mid + 1;
}
}
std::cout << ans << "\n";
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
