#include <bits/stdc++.h>
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 3e5 + 5;
struct SegTree {
};
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, s, q;
cin >> n >> s;
vector<ll> v(n+1), v2;
for(int i=1; i<=n; i++) cin >> v[i], v[i] *= (ll)1e6;
for(int i=1; i<=n; i++) v2.push_back(v[i]);
sort(v2.rbegin(), v2.rend());
while(v2.size() > 10) v2.pop_back();
cin >> q;
while(q--) {
char t;
cin >> t;
if(t == 'F') {
int p;
cin >> p;
if(p == s) {
cout << 0 << '\n';
continue;
}
int l=s, r=s, ans=0;
while(l != p && r != p) {
ans++;
if(l - 1 == 0) r++;
else if(r + 1 > n) l--;
else if(v[l-1] < v[r+1]) l--;
else r++;
}
cout << ans << '\n';
} else {
int a, b;
cin >> a >> b;
v[a] = v2[b-1] + 1;
v2.push_back(v2[a]);
v2.pop_back();
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
2908 KB |
Output isn't correct |
2 |
Incorrect |
37 ms |
1772 KB |
Output isn't correct |
3 |
Incorrect |
42 ms |
2388 KB |
Output isn't correct |
4 |
Incorrect |
49 ms |
1616 KB |
Output isn't correct |
5 |
Incorrect |
61 ms |
4308 KB |
Output isn't correct |
6 |
Incorrect |
45 ms |
4308 KB |
Output isn't correct |
7 |
Incorrect |
44 ms |
4560 KB |
Output isn't correct |
8 |
Incorrect |
52 ms |
4052 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2029 ms |
2264 KB |
Time limit exceeded |
2 |
Execution timed out |
2007 ms |
2264 KB |
Time limit exceeded |
3 |
Execution timed out |
2041 ms |
2264 KB |
Time limit exceeded |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Execution timed out |
2093 ms |
4568 KB |
Time limit exceeded |
6 |
Execution timed out |
2044 ms |
4820 KB |
Time limit exceeded |
7 |
Execution timed out |
2037 ms |
4564 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
82 ms |
596 KB |
Output isn't correct |
2 |
Incorrect |
142 ms |
632 KB |
Output isn't correct |
3 |
Execution timed out |
2064 ms |
1748 KB |
Time limit exceeded |
4 |
Execution timed out |
2073 ms |
1748 KB |
Time limit exceeded |
5 |
Incorrect |
181 ms |
592 KB |
Output isn't correct |
6 |
Execution timed out |
2059 ms |
2012 KB |
Time limit exceeded |
7 |
Incorrect |
1119 ms |
1532 KB |
Output isn't correct |
8 |
Incorrect |
183 ms |
3532 KB |
Output isn't correct |
9 |
Execution timed out |
2045 ms |
4564 KB |
Time limit exceeded |
10 |
Incorrect |
596 ms |
1360 KB |
Output isn't correct |
11 |
Execution timed out |
2024 ms |
2232 KB |
Time limit exceeded |
12 |
Execution timed out |
2099 ms |
4052 KB |
Time limit exceeded |
13 |
Execution timed out |
2023 ms |
4564 KB |
Time limit exceeded |