| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 968421 | VMaksimoski008 | Index (COCI21_index) | C++14 | 1601 ms | 13612 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt")
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> v(n+1);
for(int i=1; i<=n; i++) cin >> v[i];
vector<pii> qus(q);
for(pii &x : qus) cin >> x.first >> x.second;
vector<int> L(q, 1), R(q, 2e5), ANS(q, 1);
bool changed = 1;
while(changed) {
changed = 0;
map<int, stack<int> > to_change;
for(int i=0; i<q; i++)
if(L[i] <= R[i]) to_change[(L[i] + R[i]) / 2].push(i);
for(auto &[mid, st] : to_change) {
vector<int> pref(n+1);
for(int i=1; i<=n; i++) pref[i] = pref[i-1] + (v[i] >= mid);
while(!st.empty()) {
changed = 1;
int id = st.top();
st.pop();
if(pref[qus[id].second] - pref[qus[id].first-1] >= mid) ANS[id] = mid, L[id] = mid + 1;
else R[id] = mid - 1;
}
}
}
for(int &x : ANS) cout << x << '\n';
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
