제출 #27030

#제출 시각아이디문제언어결과실행 시간메모리
27030top34051Bulldozer (JOI17_bulldozer)C++14
0 / 100
2 ms384 KiB
#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) 메시지

bulldozer.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:32:15: warning: unused variable 'now' [-Wunused-variable]
     long long now,ans;
               ^~~
bulldozer.cpp:32:19: warning: unused variable 'ans' [-Wunused-variable]
     long long now,ans;
                   ^~~
bulldozer.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bulldozer.cpp:34:64: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d%d%lld",&p[i].x,&p[i].y,&p[i].w), p[i].id = i;
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...