#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ldb long double
struct pt{ ll x,y,w;pt(){}pt(ll a, ll b):x(a),y(b){}};
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);}
ldb abs(pt a){ return sqrt(sq(a));}
struct line
{
pt v;ll c;
line(){}
line(pt a, pt b):v(b-a),c(cross(v,a)){}
ll side(pt a){ return c-cross(v,a);}
};
const int N=2050;
pt pts[N];
int id[N];
ll cr[N],dt[N],ans;
void Solve(int n)
{
ll mx=0,sum=0,mn=0;
for(int i=1;i<=n;i++)
{
sum+=pts[id[i]].w;
mx=max(mx,sum-mn);
mn=min(mn,sum);
}
ans=max(ans,mx);
}
void Try(int n, line l)
{
for(int i=1;i<=n;i++) cr[i]=l.side(pts[i]),dt[i]=dot(pts[i],l.v),id[i]=i;
sort(id+1,id+1+n,[&](int i, int j){ return mp(cr[i],dt[i])<mp(cr[j],dt[j]);});
Solve(n);
sort(id+1,id+1+n,[&](int i, int j){ return mp(cr[i],-dt[i])<mp(cr[j],-dt[j]);});
Solve(n);
}
int main()
{
int n,i,j;
scanf("%i",&n);
for(i=1;i<=n;i++) scanf("%lld %lld %lld",&pts[i].x,&pts[i].y,&pts[i].w);
for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) Try(n,line(pts[i],pts[j]));
printf("%lld\n",ans);
return 0;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
bulldozer.cpp:50:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=1;i<=n;i++) scanf("%lld %lld %lld",&pts[i].x,&pts[i].y,&pts[i].w);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
13 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
14 ms |
428 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
8 |
Correct |
14 ms |
384 KB |
Output is correct |
9 |
Correct |
13 ms |
384 KB |
Output is correct |
10 |
Correct |
13 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
504 KB |
Output is correct |
2 |
Correct |
33 ms |
384 KB |
Output is correct |
3 |
Correct |
33 ms |
384 KB |
Output is correct |
4 |
Correct |
33 ms |
384 KB |
Output is correct |
5 |
Correct |
33 ms |
384 KB |
Output is correct |
6 |
Correct |
33 ms |
384 KB |
Output is correct |
7 |
Correct |
34 ms |
388 KB |
Output is correct |
8 |
Correct |
33 ms |
384 KB |
Output is correct |
9 |
Correct |
34 ms |
284 KB |
Output is correct |
10 |
Correct |
33 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
504 KB |
Output is correct |
2 |
Correct |
33 ms |
384 KB |
Output is correct |
3 |
Correct |
33 ms |
384 KB |
Output is correct |
4 |
Correct |
33 ms |
384 KB |
Output is correct |
5 |
Correct |
33 ms |
384 KB |
Output is correct |
6 |
Correct |
33 ms |
384 KB |
Output is correct |
7 |
Correct |
34 ms |
388 KB |
Output is correct |
8 |
Correct |
33 ms |
384 KB |
Output is correct |
9 |
Correct |
34 ms |
284 KB |
Output is correct |
10 |
Correct |
33 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
504 KB |
Output is correct |
2 |
Correct |
33 ms |
384 KB |
Output is correct |
3 |
Correct |
33 ms |
384 KB |
Output is correct |
4 |
Correct |
33 ms |
384 KB |
Output is correct |
5 |
Correct |
33 ms |
384 KB |
Output is correct |
6 |
Correct |
33 ms |
384 KB |
Output is correct |
7 |
Correct |
34 ms |
388 KB |
Output is correct |
8 |
Correct |
33 ms |
384 KB |
Output is correct |
9 |
Correct |
34 ms |
284 KB |
Output is correct |
10 |
Correct |
33 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
384 KB |
Output is correct |
2 |
Correct |
15 ms |
384 KB |
Output is correct |
3 |
Correct |
13 ms |
384 KB |
Output is correct |
4 |
Correct |
13 ms |
384 KB |
Output is correct |
5 |
Correct |
14 ms |
384 KB |
Output is correct |
6 |
Correct |
14 ms |
428 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
8 |
Correct |
14 ms |
384 KB |
Output is correct |
9 |
Correct |
13 ms |
384 KB |
Output is correct |
10 |
Correct |
13 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |