# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101403 | cheeheng | 케이크 (CEOI14_cake) | C++14 | 2099 ms | 17192 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
int d[250005];
int o[250005];
int N, a;
set<ii> di;
void sim(int a){
int l = a;
int r = a;
o[a] = 0;
int cnt = 1;
for(int i = 1; i < N; i ++){
int tempL = l-1;
int tempR = r+1;
if(tempL == -1){
r = tempR;
o[tempR] = cnt++;
//printf("o[%d] = %d\n", tempR, cnt-1);
}else if(tempR == N){
l = tempL;
o[tempL] = cnt++;
//printf("o[%d] = %d\n", tempL, cnt-1);
}else if(d[tempL] < d[tempR]){
l = tempL;
o[tempL] = cnt++;
//printf("o[%d] = %d\n", tempL, cnt-1);
}else{
r = tempR;
o[tempR] = cnt++;
//printf("o[%d] = %d\n", tempR, cnt-1);
}
}
}
void e(int a, int pos){
set<ii> temp;
for(int i = 1; i < pos; i ++){
ii temp2 = *(--di.end());
di.erase(temp2);
temp.insert(ii(temp2.first+1, temp2.second));
d[temp2.second] = temp2.first+1;
}
ii temp3 = *(--di.end());
d[a] = temp3.first+1;
temp.insert(ii(temp3.first+1, a));
for(ii x: temp){
di.insert(x);
}
for(int i = 0; i < N; i ++){
//printf("d[%d] = %d\n", i, d[i]);
}
}
int main(){
scanf("%d%d", &N, &a);
a --;
for(int i = 0; i < N; i ++){
scanf("%d", &d[i]);
di.insert(ii(d[i], i));
}
int Q;
scanf("%d", &Q);
sim(a);
for(int i = 0; i < Q; i ++){
char op;
scanf(" %c", &op);
if(op == 'F'){
int x;
scanf("%d", &x);
printf("%d\n", o[x-1]);
}else{
int b, pos;
scanf("%d%d", &b, &pos);
e(b-1, pos);
sim(a);
}
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |