| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 27030 | top34051 | Bulldozer (JOI17_bulldozer) | C++14 | 2 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define maxn 2005
struct node {
int id,x,y;
long long w;
};
int n;
long long sum[maxn];
long long mx[maxn*4];
long long L[maxn*4];
long long R[maxn*4];
node p[maxn];
bool cmp(node x,node y) {
if(x.x!=y.x) return x.x<y.x;
return x.y<y.y;
}
void update(int pos,int l,int r,int x,long long val) {
if(l>x || r<x) return ;
if(l==r) {
mx[pos] = L[pos] = R[pos] = val;
return ;
}
int mid = (l+r)/2;
update(pos<<1,l,mid,x,val); update(pos<<1|1,mid+1,r,x,val);
mx[pos] = max(max(mx[pos<<1],mx[pos<<1|1]),max(0LL,L[pos<<1|1]) + max(0LL,R[pos<<1]));
L[pos] = L[pos<<1] + ((L[pos<<1]==sum[mid]-sum[l-1]) ? max(0LL,L[pos<<1|1]) : 0LL);
R[pos] = R[pos<<1|1] + ((R[pos<<1|1]==sum[r]-sum[mid]) ? max(0LL,R[pos<<1]) : 0LL);
}
main() {
int i;
long long now,ans;
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d%d%lld",&p[i].x,&p[i].y,&p[i].w), p[i].id = i;
sort(&p[1],&p[n+1],cmp);
for(i=1;i<=n;i++) sum[i] = sum[i-1] + p[i].w;
for(i=1;i<=n;i++) update(1,1,n,i,p[i].w);
printf("%lld",max(0LL,mx[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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
