#include <bits/stdc++.h>
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define fi first
#define se second
#define INF 1e7
#define unsigned u
#define eps 1e-18
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 100005;
vi s;
int main() {
optimise;
int n,start;
cin >> n >> start;
start--;
for (int i = 0; i < n; ++i)
{
int a;
cin >> a;
s.pb(a);
}
int q;
cin >> q;
while(q--){
char be;
cin >> be;
if(be == 'F'){
int a;
cin >> a;
a--;
int l, r;
if(start > 0) l = start-1;
else l = -1;
if(start < n-1) r = start+1;
else r = -1;
int cur = start, i = 0;
while(cur != a){
//cout << cur << " ";
if(l==-1) cur = r, r++;
else if(r==-1) cur = l, l--;
else if(s[r] < s[l]){
cur = r;
r++;
} else if(s[r] > s[l]){
cur = l;
l--;
}
if(r == n) r = -1;
i++;
}
cout << i << endl;
} else {
int a,b;
cin >> a >> b;
a--;
b = n-b+1;
for (int i = 0; i < n; ++i)
{
if(s[i] <= b && s[i]>s[a])
s[i]--;
}
s[a] = b;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
17 ms |
364 KB |
Output is correct |
5 |
Correct |
271 ms |
548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2069 ms |
1408 KB |
Time limit exceeded |
2 |
Execution timed out |
2086 ms |
1668 KB |
Time limit exceeded |
3 |
Execution timed out |
2073 ms |
1476 KB |
Time limit exceeded |
4 |
Execution timed out |
2083 ms |
1668 KB |
Time limit exceeded |
5 |
Execution timed out |
2090 ms |
1020 KB |
Time limit exceeded |
6 |
Execution timed out |
2090 ms |
1276 KB |
Time limit exceeded |
7 |
Execution timed out |
2084 ms |
1220 KB |
Time limit exceeded |
8 |
Execution timed out |
2090 ms |
1276 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2096 ms |
1888 KB |
Time limit exceeded |
2 |
Execution timed out |
2085 ms |
2156 KB |
Time limit exceeded |
3 |
Execution timed out |
2092 ms |
2264 KB |
Time limit exceeded |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Execution timed out |
2084 ms |
3344 KB |
Time limit exceeded |
6 |
Execution timed out |
2082 ms |
3332 KB |
Time limit exceeded |
7 |
Execution timed out |
2097 ms |
3392 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
420 ms |
744 KB |
Output is correct |
2 |
Correct |
708 ms |
860 KB |
Output is correct |
3 |
Execution timed out |
2098 ms |
1272 KB |
Time limit exceeded |
4 |
Execution timed out |
2092 ms |
1480 KB |
Time limit exceeded |
5 |
Correct |
889 ms |
1716 KB |
Output is correct |
6 |
Execution timed out |
2096 ms |
1488 KB |
Time limit exceeded |
7 |
Execution timed out |
2096 ms |
1588 KB |
Time limit exceeded |
8 |
Execution timed out |
2077 ms |
1604 KB |
Time limit exceeded |
9 |
Execution timed out |
2098 ms |
3256 KB |
Time limit exceeded |
10 |
Execution timed out |
2097 ms |
3908 KB |
Time limit exceeded |
11 |
Execution timed out |
2088 ms |
1224 KB |
Time limit exceeded |
12 |
Execution timed out |
2094 ms |
2760 KB |
Time limit exceeded |
13 |
Execution timed out |
2083 ms |
3336 KB |
Time limit exceeded |