이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
const int N=2048;
const int M=2*N;
ll l[M],r[M],sum[M],ans[M];
int A[N];
void pull(int c)
{
ans[c]=max(max(ans[c<<1],ans[c<<1|1]),r[c<<1]+l[c<<1|1]);
l[c]=max(l[c<<1],sum[c<<1]+l[c<<1|1]);
r[c]=max(r[c<<1|1],sum[c<<1|1]+r[c<<1]);
sum[c]=sum[c<<1]+sum[c<<1|1];
}
void Build()
{
for(int i=N;i<M;i++) sum[i]=A[i-N],l[i]=r[i]=ans[i]=max(0,A[i-N]);
for(int i=N-1;i;i--) pull(i);
}
void Set(int qi, int x)
{
qi+=N;sum[qi]=x;l[qi]=r[qi]=ans[qi]=max(x,0);
for(qi>>=1;qi;qi>>=1) pull(qi);
}
struct pt{ ll x,y,w;pt(){}pt(ll a, ll b):x(a),y(b){}};
bool operator < (pt a, pt b){ return mp(a.y,a.x)<mp(b.y,b.x);}
pt operator - (pt a, pt b){ return pt(a.x-b.x,a.y-b.y);}
ll cross(pt a, pt b){ return a.x*b.y-a.y*b.x;}
ll dot(pt a, pt b){ return a.x*b.x+a.y*b.y;}
ll sq(pt a){ return dot(a,a);}
int part(pt a){ return a<pt(0,0);}
#define ldb double
const ldb PI=acos(-1);
ldb angle(pt a)
{
ldb ang=atan2(a.y,a.x);
if(ang<0) ang+=2*PI;
return ang;
}
bool comp(pt a, pt b){ return mt(part(a),(ll)0)<mt(part(b),cross(a,b));}
bool eq(pt a, pt b){ return comp(a,b)==comp(b,a);}
pt P[N];
int w[N],id[N],pos[N];
ll sol;
void SW(int x, int y)
{
swap(pos[x],pos[y]);
Set(pos[x],P[x].w);
Set(pos[y],P[y].w);
}
ll cross(ll ax, ll ay, ll bx, ll by){ return ax*by-ay*bx;}
struct Event
{
ll x,y;
int i,j;
Event(){}
Event(ll a, ll b, int c, int d):x(a),y(b),i(c),j(d){}
bool operator < (Event b){ return cross(x,y,b.x,b.y)==0?mp(i,j)<mp(b.i,b.j):cross(x,y,b.x,b.y)>0;}
} evs[N*N];
int main()
{
int n;
scanf("%i",&n);
for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&P[i].x,&P[i].y,&P[i].w),id[i]=i;
sort(P+1,P+1+n);
for(int i=1;i<=n;i++) A[i]=P[i].w,pos[i]=i;
Build();
sol=ans[1];
int tot=0;
for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++)
{
pt d=P[i]-P[j];
if(part(d)==1) d=pt(0,0)-d;
evs[++tot]=Event(d.x,d.y,i,j);
}
sort(evs+1,evs+1+tot);
for(int i=1,j;i<=tot;i=j)
{
for(j=i;j<=tot && cross(evs[i].x,evs[i].y,evs[j].x,evs[j].y)==0;j++) SW(evs[j].i,evs[j].j);
sol=max(sol,ans[1]);
}
printf("%lld\n",sol);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
bulldozer.cpp:67:74: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++) scanf("%lld %lld %lld",&P[i].x,&P[i].y,&P[i].w),id[i]=i;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# | 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... |