# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242344 | SomeoneUnknown | 3단 점프 (JOI19_jumps) | C++14 | 169 ms | 40164 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct nodei{
int lo, hi, mid, val;
int lazyclr;
nodei *lft, *rght;
nodei(int l, int h){
lo = l;
hi = h;
mid = (l+h)/2;
val = 0;
lazyclr = 0;
if(h<l) exit(-1);
if(l<h){
lft = new nodei(l, mid);
rght = new nodei(mid+1, h);
}
}
void propogate(){
//if(!lazyclr) return;
//val = 0;
if(lo<hi){
lft->lazyclr += lazyclr;
rght->lazyclr += lazyclr;
}
val += lazyclr;
lazyclr = 0;
}
int queryf(){
propogate();
if(lo == hi) return lo;
lft->propogate();
rght->propogate();
if(lft->val < rght->val){
return rght->queryf();
}else{
return lft->queryf();
}
}
int queryr(int l, int h){
propogate();
if(l <= lo && h >= hi) return val;
if(l > mid) return rght->queryr(l, h);
if(h <= mid) return lft->queryr(l, h);
return max(lft->queryr(l, h), rght->queryr(l, h));
}
void update(int l, int h, int v){
propogate();
if(l <= lo && h >= hi){
lazyclr += v;
return;
}
if(h > mid) rght->update(l, h, v);
if(l <= mid) lft->update(l, h, v);
lft->propogate();
rght->propogate();
val = max(lft->val, rght->val);
} //write query!
} *rootv, *rootc;
int main(){
int n;
scanf("%d", &n);
rootv = new nodei(0, n-1);
int firm[n];
for(int i = 0; i < n; ++i){
scanf("%d", &firm[i]);
rootv->update(i, i, firm[i]);
}
int best[n][n];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
best[i][j] = 0;
if(j <= i+1){
continue;
}
int base = firm[i]+firm[j];
best[i][j] = rootv->queryr(i+1, (i+j)/2);
}
}
int q;
scanf("%d", &q);
for(int i = 0; i < q; i++){
int a, c;
scanf("%d %d", &a, &c);
int cbest = 0;
for(int j = a; j < c; j++){
for(int k = j+2; k <= c; k++){
cbest = max(cbest, best[j-1][k-1]);
}
}
printf("%d\n", cbest);
}
}
컴파일 시 표준 에러 (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... |