#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;}
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 sum=0;
for(int i=1;i<=n;i++)
{
sum+=pts[id[i]].w;
if(sum<0) sum=0;
ans=max(ans,sum);
}
}
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 pts[i].x<pts[j].x;});
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);
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);
Try(n,line());
//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:47:10: warning: unused variable 'j' [-Wunused-variable]
int n,i,j;
^
bulldozer.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
bulldozer.cpp:49: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);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
356 KB |
Output is correct |
13 |
Correct |
2 ms |
304 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
356 KB |
Output is correct |
13 |
Correct |
2 ms |
304 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |