# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83635 | wjoao | Kralj (COCI16_kralj) | C++11 | 804 ms | 43436 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define maxn 500010
using namespace std;
int n, dwarves[maxn], a, elves[maxn], sobras[maxn];
vector<int> f[maxn];
int main(){
scanf(" %d", &n);
for(int i = 1; i <= n; i++){
scanf(" %d", &a);
f[a].push_back(i);
}
for(int i = 1; i <= n; i++) scanf(" %d", &dwarves[i]);
for(int i = 1; i <= n; i++) scanf(" %d", &elves[i]);
for(int k = 0, j = 1, sobra = 0; k < 3*n; k++, j++, sobra--){
if( j == n+1 ) j = 1;
sobra = max(0, sobra);
sobras[j] = max(sobra, sobras[j]);
sobra += f[j].size();
}
int start_point;
for(int i = 1; i <= n; i++){
if(sobras[i] == 0){
start_point = i;
break;
}
}
int vitorias = 0;
int j = start_point;
set<int> pokemon;
while(true){
for(int k = 0; k < f[j].size(); k++){
pokemon.insert(elves[f[j][k]]);
}
set<int>::iterator it = pokemon.upper_bound(dwarves[j]);
if(it == pokemon.end()){
it = pokemon.begin();
}
if( *it > dwarves[j]) {
vitorias++;
}
pokemon.erase(it);
j++;
if( j == n+1 ) j = 1;
if( j == start_point ) break;
}
printf("%d\n", vitorias);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |