답안 #109530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109530 2019-05-06T19:59:41 Z TadijaSebez Bulldozer (JOI17_bulldozer) C++11
25 / 100
2000 ms 504 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 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),ans=max(ans,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:46:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
bulldozer.cpp:47:73: 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),ans=max(ans,pts[i].w);
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 13 ms 392 KB Output is correct
5 Correct 14 ms 432 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 14 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 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 32 ms 384 KB Output is correct
4 Correct 33 ms 388 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 33 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 32 ms 384 KB Output is correct
10 Correct 33 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 31 ms 384 KB Output is correct
22 Correct 31 ms 384 KB Output is correct
23 Correct 30 ms 384 KB Output is correct
24 Correct 30 ms 384 KB Output is correct
25 Correct 30 ms 384 KB Output is correct
26 Correct 31 ms 384 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 30 ms 384 KB Output is correct
29 Correct 30 ms 384 KB Output is correct
30 Correct 31 ms 384 KB Output is correct
31 Correct 30 ms 384 KB Output is correct
32 Correct 31 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 32 ms 384 KB Output is correct
4 Correct 33 ms 388 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 33 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 32 ms 384 KB Output is correct
10 Correct 33 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 31 ms 384 KB Output is correct
22 Correct 31 ms 384 KB Output is correct
23 Correct 30 ms 384 KB Output is correct
24 Correct 30 ms 384 KB Output is correct
25 Correct 30 ms 384 KB Output is correct
26 Correct 31 ms 384 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 30 ms 384 KB Output is correct
29 Correct 30 ms 384 KB Output is correct
30 Correct 31 ms 384 KB Output is correct
31 Correct 30 ms 384 KB Output is correct
32 Correct 31 ms 384 KB Output is correct
33 Execution timed out 2037 ms 384 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 384 KB Output is correct
2 Correct 33 ms 384 KB Output is correct
3 Correct 32 ms 384 KB Output is correct
4 Correct 33 ms 388 KB Output is correct
5 Correct 33 ms 384 KB Output is correct
6 Correct 33 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 32 ms 384 KB Output is correct
10 Correct 33 ms 504 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 31 ms 384 KB Output is correct
22 Correct 31 ms 384 KB Output is correct
23 Correct 30 ms 384 KB Output is correct
24 Correct 30 ms 384 KB Output is correct
25 Correct 30 ms 384 KB Output is correct
26 Correct 31 ms 384 KB Output is correct
27 Correct 30 ms 384 KB Output is correct
28 Correct 30 ms 384 KB Output is correct
29 Correct 30 ms 384 KB Output is correct
30 Correct 31 ms 384 KB Output is correct
31 Correct 30 ms 384 KB Output is correct
32 Correct 31 ms 384 KB Output is correct
33 Execution timed out 2037 ms 384 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 13 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 13 ms 392 KB Output is correct
5 Correct 14 ms 432 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 14 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 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 33 ms 384 KB Output is correct
17 Correct 33 ms 384 KB Output is correct
18 Correct 32 ms 384 KB Output is correct
19 Correct 33 ms 388 KB Output is correct
20 Correct 33 ms 384 KB Output is correct
21 Correct 33 ms 384 KB Output is correct
22 Correct 32 ms 384 KB Output is correct
23 Correct 32 ms 384 KB Output is correct
24 Correct 32 ms 384 KB Output is correct
25 Correct 33 ms 504 KB Output is correct
26 Correct 2 ms 256 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 31 ms 384 KB Output is correct
37 Correct 31 ms 384 KB Output is correct
38 Correct 30 ms 384 KB Output is correct
39 Correct 30 ms 384 KB Output is correct
40 Correct 30 ms 384 KB Output is correct
41 Correct 31 ms 384 KB Output is correct
42 Correct 30 ms 384 KB Output is correct
43 Correct 30 ms 384 KB Output is correct
44 Correct 30 ms 384 KB Output is correct
45 Correct 31 ms 384 KB Output is correct
46 Correct 30 ms 384 KB Output is correct
47 Correct 31 ms 384 KB Output is correct
48 Execution timed out 2037 ms 384 KB Time limit exceeded
49 Halted 0 ms 0 KB -