#include <bits/stdc++.h>
typedef int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
//#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
using namespace std;
const int N=3e5+100;
ll val[N];
ll b[N];
ll a,n;
void solve(){
b[a]=0;
val[0]=1e9;
val[n+1]=1e9;
ll l=a-1,r=a+1;
for (int i=1;i<n;i++){
if (val[l]<val[r]){
b[l]=i;
l--;
}
else{
b[r]=i;
r++;
}
}
}
int32_t main(){
sync;
cin >> n >> a;
for (int i=1;i<=n;i++){
cin >> val[i];
}
solve();
ll q;
cin >> q;
for (int i=0;i<q;i++){
char c;
cin >> c;
if (c=='E'){
ll id,cnt;
cin >> id >> cnt;
cnt=n-cnt+1;
for (int j=1;j<=n;j++){
if (val[j]<=cnt && val[j]>=val[id]) val[j]--;
}
val[id]=cnt;
solve();
}
else{
ll id;
cin >> id;
cout << b[id] << endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2041 ms |
376 KB |
Time limit exceeded |
2 |
Execution timed out |
2050 ms |
376 KB |
Time limit exceeded |
3 |
Execution timed out |
2054 ms |
380 KB |
Time limit exceeded |
4 |
Execution timed out |
2020 ms |
376 KB |
Time limit exceeded |
5 |
Execution timed out |
2058 ms |
504 KB |
Time limit exceeded |
6 |
Execution timed out |
2023 ms |
508 KB |
Time limit exceeded |
7 |
Execution timed out |
2094 ms |
504 KB |
Time limit exceeded |
8 |
Execution timed out |
2017 ms |
504 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
84 ms |
1728 KB |
Output is correct |
2 |
Correct |
52 ms |
1656 KB |
Output is correct |
3 |
Correct |
51 ms |
1656 KB |
Output is correct |
4 |
Incorrect |
0 ms |
376 KB |
Output isn't correct |
5 |
Correct |
143 ms |
3084 KB |
Output is correct |
6 |
Incorrect |
132 ms |
3068 KB |
Output isn't correct |
7 |
Correct |
90 ms |
2732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
403 ms |
488 KB |
Output isn't correct |
2 |
Incorrect |
664 ms |
512 KB |
Output isn't correct |
3 |
Execution timed out |
2079 ms |
888 KB |
Time limit exceeded |
4 |
Execution timed out |
2073 ms |
1016 KB |
Time limit exceeded |
5 |
Incorrect |
803 ms |
864 KB |
Output isn't correct |
6 |
Execution timed out |
2088 ms |
1036 KB |
Time limit exceeded |
7 |
Execution timed out |
2004 ms |
760 KB |
Time limit exceeded |
8 |
Execution timed out |
2015 ms |
1148 KB |
Time limit exceeded |
9 |
Execution timed out |
2088 ms |
2352 KB |
Time limit exceeded |
10 |
Execution timed out |
2007 ms |
1712 KB |
Time limit exceeded |
11 |
Execution timed out |
2029 ms |
1272 KB |
Time limit exceeded |
12 |
Execution timed out |
2065 ms |
2596 KB |
Time limit exceeded |
13 |
Execution timed out |
2060 ms |
3116 KB |
Time limit exceeded |