| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 25948 | kdh9949 | Cake (CEOI14_cake) | C++14 | 706 ms | 5048 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, q, p, a[250010];
struct Dat{
int i;
bool operator<(const Dat &oth) const {
return a[i] < a[oth.i];
}
};
set<Dat> t10;
const int sz = 262144;
struct Seg{
int dat[2 * sz];
void upd(int x, int v){
x += sz; dat[x] = v;
for(x /= 2; x; x /= 2) dat[x] = max(dat[2 * x], dat[2 * x + 1]);
}
int get(int s, int e){
int ret = 0;
for(s += sz, e += sz; s <= e; s /= 2, e /= 2){
if(s % 2 == 1) ret = max(ret, dat[s++]);
if(e % 2 == 0) ret = max(ret, dat[e--]);
}
return ret;
}
int pos(int t, int v){
int x;
if(t == 0){
for(x = p + 1 + sz; __builtin_popcount(x + 1) != 1; x = (x + 1) / 2){
if(dat[x] > v) break;
}
}
else{
for(x = p - 1 + sz; __builtin_popcount(x) != 1; x = (x - 1) / 2){
if(dat[x] > v) break;
}
}
for(; x < sz; ){
if(dat[2 * x + t] > v) x = 2 * x + t;
else x = 2 * x + !t;
}
return x - sz;
}
} S;
int main(){
scanf("%d%d", &n, &p);
for(int i = 1; i <= n; i++){
scanf("%d", a + i);
S.upd(i, a[i]);
t10.insert({i});
while(t10.size() > 10) t10.erase(t10.begin());
}
S.upd(0, (int)1e9);
S.upd(n + 1, (int)1e9);
scanf("%d", &q);
for(int x, y; q--; ){
char buf[3]; scanf("%s", buf);
if(buf[0] == 'E'){
scanf("%d%d", &x, &y);
int t = a[(*t10.rbegin()).i];
vector<int> v;
for(int i = 0; i < y - 1; i++){
int u = (*t10.rbegin()).i;
t10.erase(*t10.rbegin());
a[u] = t + y - i;
S.upd(u, a[u]);
v.push_back(u);
}
t10.erase({x});
a[x] = t + 1;
S.upd(x, a[x]);
t10.insert({x});
for(auto &i : v) t10.insert({i});
while(t10.size() > 10) t10.erase(t10.begin());
}
else{
scanf("%d", &x);
if(x < p) printf("%d\n", S.pos(0, S.get(x, p - 1)) - x - 1);
else if(x == p) puts("0");
else printf("%d\n", x - S.pos(1, S.get(p + 1, x)) - 1);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
