Submission #109528

# Submission time Handle Problem Language Result Execution time Memory
109528 2019-05-06T19:54:28 Z TadijaSebez Bulldozer (JOI17_bulldozer) C++11
0 / 100
8 ms 392 KB
#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);
	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: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);
                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 8 ms 392 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 8 ms 392 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Incorrect 1 ms 256 KB Output isn't correct
13 Halted 0 ms 0 KB -