Submission #84012

#TimeUsernameProblemLanguageResultExecution timeMemory
84012Saboon케이크 (CEOI14_cake)C++14
0 / 100
2073 ms36716 KiB
#include <bits/stdc++.h> #define MP make_pair #define F first #define PB push_back #define S second using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const int maxn = 3e5 + 4; int a[maxn], pos[maxn]; int main (){ ios_base::sync_with_stdio(false); int n, st; cin >> n >> st; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] = n - a[i] + 1; } int ptr1 = st - 1, ptr2 = st + 1, tmp = 1; while (ptr1 >= 1 or ptr2 <= n) { if (ptr1 < 1) { pos[ptr2 ++] = tmp ++; } else if (ptr2 > n) { pos[ptr1 --] = tmp ++; } else { if (a[ptr1] > a[ptr2]) { pos[ptr1 --] = tmp ++; } else { pos[ptr2 ++] = tmp ++; } } } int m; cin >> m; for (int i = 0; i < m; i++) { char type; cin >> type; if (type == 'F') { int idx; cin >> idx; cout << pos[idx] << '\n'; } else { int idx, x; cin >> idx >> x; for (int j = 1; j <= n; j++) { if (a[i] >= x and a[i] < a[idx]) { a[i] ++; } } a[idx] = x; int ptr1 = st - 1, ptr2 = st + 1, tmp = 1; while (ptr1 >= 1 or ptr2 <= n) { if (ptr1 < 1) { pos[ptr2 ++] = tmp ++; } else if (ptr2 > n) { pos[ptr1 --] = tmp ++; } else { if (a[ptr1] > a[ptr2]) { pos[ptr1 --] = tmp ++; } else { pos[ptr2 ++] = tmp ++; } } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...