This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int ll
typedef long long ll;
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
signed main()
{
FAST;
int n, a;
cin >> n >> a;
int arr[n+2];
arr[n + 1] = LLONG_MAX;
for(int i = 1; i <= n; i++) cin >> arr[i];
int q;
cin >> q;
while(q--) {
char t;
cin >> t;
if(t == 'F') {
int x;
cin >> x;
int cnt = 1;
if(a == x) cout << 0 << endl;
else {
int l = a - 1, r = a + 1;
bool flag = 1;
while(flag) {
cout << arr[l] << ' ' << arr[r] << endl;
if(l > 1 && arr[l] < arr[r]) l--;
else if(r <= n) r++;
else l--;
if(l < x && r > x) {
flag = 0;
break;
}
cnt++;
}
cout << cnt << endl;
}
}
else {
int x, y;
cin >> x >> y;
arr[x] += y;
}
}
}
# | 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... |