#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl "\n"
const int mod = (int) 1e9+7;
const int N=2e5+5;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,a; cin>>n>>a;
int d[n+5],opd[n+5];
for (int i=1;i<=n;i++) {
cin>>d[i];
opd[d[i]]=i;
}
int when[n+5];
when[a]=0;
int l=a-1,r=a+1,time=1;
while (l>=1 || r<=n) {
if (l>=1 && ((r>n) || (r<=n && d[l]<d[r]))) {
when[l]=time; time++; l--;
}
if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
when[r]=time; time++; r++;
}
}
int q; cin>>q;
while (q--) {
char c; cin>>c;
if (c=='F') {
int x; cin>>x;
cout<<when[x]<<endl;
}
else {
int x,nw; cin>>x>>nw;
nw=n-(nw-1);
for (int i=nw;i>d[x];i--) {
d[opd[i]]--;
}
d[x]=nw;
int l=a-1,r=a+1,time=1;
while (l>=1 || r<=n) {
if (l>=1 && ((r>n) || (r<=n && d[l]<d[r]))) {
when[l]=time; time++; l--;
}
if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
when[r]=time; time++; r++;
}
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2072 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2060 ms |
484 KB |
Time limit exceeded |
2 |
Execution timed out |
2081 ms |
468 KB |
Time limit exceeded |
3 |
Execution timed out |
2076 ms |
596 KB |
Time limit exceeded |
4 |
Execution timed out |
2077 ms |
632 KB |
Time limit exceeded |
5 |
Execution timed out |
2068 ms |
980 KB |
Time limit exceeded |
6 |
Execution timed out |
2086 ms |
980 KB |
Time limit exceeded |
7 |
Execution timed out |
2090 ms |
968 KB |
Time limit exceeded |
8 |
Execution timed out |
2092 ms |
980 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2089 ms |
2908 KB |
Time limit exceeded |
2 |
Execution timed out |
2084 ms |
2764 KB |
Time limit exceeded |
3 |
Execution timed out |
2081 ms |
2788 KB |
Time limit exceeded |
4 |
Execution timed out |
2094 ms |
212 KB |
Time limit exceeded |
5 |
Execution timed out |
2052 ms |
6648 KB |
Time limit exceeded |
6 |
Execution timed out |
2071 ms |
6476 KB |
Time limit exceeded |
7 |
Execution timed out |
2055 ms |
6348 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2079 ms |
372 KB |
Time limit exceeded |
2 |
Execution timed out |
2074 ms |
340 KB |
Time limit exceeded |
3 |
Execution timed out |
2075 ms |
1492 KB |
Time limit exceeded |
4 |
Execution timed out |
2045 ms |
1612 KB |
Time limit exceeded |
5 |
Execution timed out |
2064 ms |
340 KB |
Time limit exceeded |
6 |
Execution timed out |
2063 ms |
2004 KB |
Time limit exceeded |
7 |
Execution timed out |
2066 ms |
468 KB |
Time limit exceeded |
8 |
Execution timed out |
2076 ms |
2772 KB |
Time limit exceeded |
9 |
Execution timed out |
2043 ms |
6348 KB |
Time limit exceeded |
10 |
Execution timed out |
2089 ms |
340 KB |
Time limit exceeded |
11 |
Execution timed out |
2077 ms |
852 KB |
Time limit exceeded |
12 |
Execution timed out |
2081 ms |
5076 KB |
Time limit exceeded |
13 |
Execution timed out |
2070 ms |
6268 KB |
Time limit exceeded |