이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn=1e4+5;
int a[maxn];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, x;
cin >> n >> x;
x--;
for(int i=0; i<n; i++){
cin >> a[i];
}
int q;
cin >> q;
char c;
int e, f;
int pos, br;
int l, d;
for(int i=0; i<q; i++){
cin >> c >> e;
e--;
if(c=='F'){
pos=x;
br=0;
l=pos-1;
d=pos+1;
while(pos!=e){
br++;
if(l==-1 || (d<n && a[l]>a[d])){
pos=d;
d++;
}
else{
pos=l;
l--;
}
}
cout << br << '\n';
}
else{
cin >> f;
f--;
f=n-f;
if(f>a[e]){
for(int j=0; j<n; j++){
if(a[j]>a[e] && a[j]<=f){
a[j]--;
}
}
a[e]=f;
}
else if(f<a[e]){
for(int j=0; j<n; j++){
if(a[j]>=f && a[j]<a[e]){
a[j]++;
}
a[e]=f;
}
}
}
}
return 0;
}
| # | 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... |