답안 #109526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109526 2019-05-06T19:49:33 Z TadijaSebez Bulldozer (JOI17_bulldozer) C++11
0 / 100
34 ms 420 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;}
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 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 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);
                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 15 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 13 ms 384 KB Output is correct
7 Correct 13 ms 384 KB Output is correct
8 Correct 13 ms 384 KB Output is correct
9 Correct 13 ms 384 KB Output is correct
10 Correct 14 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 356 KB Output is correct
2 Correct 32 ms 384 KB Output is correct
3 Correct 32 ms 420 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
5 Correct 34 ms 384 KB Output is correct
6 Correct 32 ms 384 KB Output is correct
7 Correct 32 ms 384 KB Output is correct
8 Correct 32 ms 384 KB Output is correct
9 Correct 33 ms 384 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 356 KB Output is correct
2 Correct 32 ms 384 KB Output is correct
3 Correct 32 ms 420 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
5 Correct 34 ms 384 KB Output is correct
6 Correct 32 ms 384 KB Output is correct
7 Correct 32 ms 384 KB Output is correct
8 Correct 32 ms 384 KB Output is correct
9 Correct 33 ms 384 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 356 KB Output is correct
2 Correct 32 ms 384 KB Output is correct
3 Correct 32 ms 420 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
5 Correct 34 ms 384 KB Output is correct
6 Correct 32 ms 384 KB Output is correct
7 Correct 32 ms 384 KB Output is correct
8 Correct 32 ms 384 KB Output is correct
9 Correct 33 ms 384 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 15 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 13 ms 384 KB Output is correct
7 Correct 13 ms 384 KB Output is correct
8 Correct 13 ms 384 KB Output is correct
9 Correct 13 ms 384 KB Output is correct
10 Correct 14 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Incorrect 2 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -