# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
163050 | _qVp_ | Kralj (COCI16_kralj) | C++14 | 919 ms | 53164 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair < int, int > II;
const int md = 5e5 + 10;
int n;
int a[md], b[md], pre[md];
vector < int > adj[md];
int solve(int start) {
int res = 0;
set < int > S;
for(int i = start, j = 1; j <= n; j++, i = i % n + 1) {
for(int j = 0; j < adj[i].size(); j++)
S.insert(adj[i][j]);
set < int > :: iterator it = S.upper_bound(b[i]);
if (it == S.end())
S.erase(S.begin());
else {
S.erase(it);
res++;
}
}
return res;
}
int main() {
//freopen("test.in", "r", stdin);
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
pre[i] = -1;
}
for(int i = 1; i <= n; i++)
cin >> b[i];
II start = II(1e9, 1e9);
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
adj[a[i]].push_back(x);
//cout << a[i] << " " << x << endl;
pre[a[i]]++;
}
for(int i = 1; i <= n; i++) {
pre[i] += pre[i - 1];
start = min(start, II(pre[i], i));
}
cout << solve(start.second % n + 1);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |