답안 #101018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101018 2019-03-16T04:20:53 Z autumn_eel Bulldozer (JOI17_bulldozer) C++14
25 / 100
30 ms 512 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
};
double norm(Point p){
	return p.x*p.x+p.y*p.y;
}
double abs(Point p){
	return sqrt(norm(p));
}

Point operator-(Point a,Point b){
	return Point(b.x-a.x,b.y-a.y);
}
double det(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}

struct Line{
	Point a,b;
	Line(){}
	Line(Point a,Point b):a(a),b(b){}
};
double dist(Line l,Point p){
	return det(p-l.a,l.b-l.a)/abs(l.b-l.a);
}


Point p[200];
ll w[200];

int main(){
	int n;cin>>n;
	if(n>100)abort();
	bool ok=true;
	rep(i,n){
		scanf("%lf%lf%lld",&p[i].x,&p[i].y,&w[i]);
		if(p[i].y){
			ok=false;
		}
	}
	if(n==1){
		cout<<max(w[0],0LL)<<endl;
		return 0;
	}
	if(ok){
		vector<pair<double,int>>v;
		rep(i,n){
			v.push_back(make_pair(p[i].x,w[i]));
		}
		sort(v.begin(),v.end());
		ll Max=0;
		rep(i,n){
			ll sum=0;
			for(int j=i;j<n;j++){
				sum+=v[j].second;
				Max=max(Max,sum);
			}
		}
		cout<<Max<<endl;
		return 0;
	}
	ll ans=0;
	rep(i,n)for(int j=i+1;j<n;j++){
		Line l(p[i],p[j]);
		vector<pair<double,int>>v;
		for(int k=0;k<n;k++){
			v.push_back(make_pair(dist(l,p[k]),w[k]));
		}
		sort(v.begin(),v.end());
		ll Min=0,sum=0,Max=0;
		int id=-1;
		rep(i,v.size()){
			sum+=v[i].second;
			Max=max(Max,sum-Min);
			Min=min(Min,sum);
			if(v[i].first==0)id=i;
		}
		swap(v[id-1],v[id]);
		Min=0,sum=0,Max=0;
		rep(i,v.size()){
			sum+=v[i].second;
			Max=max(Max,sum-Min);
			Min=min(Min,sum);
		}
		ans=max(ans,Max);
	}
	cout<<ans<<endl;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:2:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n)for(int i=0;i<(n);i++)
                              ^
bulldozer.cpp:80:3: note: in expansion of macro 'rep'
   rep(i,v.size()){
   ^~~
bulldozer.cpp:2:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,n)for(int i=0;i<(n);i++)
                              ^
bulldozer.cpp:88:3: note: in expansion of macro 'rep'
   rep(i,v.size()){
   ^~~
bulldozer.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf%lf%lld",&p[i].x,&p[i].y,&w[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 256 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 28 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 28 ms 256 KB Output is correct
6 Correct 29 ms 384 KB Output is correct
7 Correct 28 ms 256 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Correct 29 ms 384 KB Output is correct
10 Correct 30 ms 384 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 304 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 29 ms 384 KB Output is correct
23 Correct 27 ms 256 KB Output is correct
24 Correct 27 ms 256 KB Output is correct
25 Correct 28 ms 256 KB Output is correct
26 Correct 27 ms 368 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 27 ms 256 KB Output is correct
29 Correct 27 ms 432 KB Output is correct
30 Correct 27 ms 384 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 256 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 28 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 28 ms 256 KB Output is correct
6 Correct 29 ms 384 KB Output is correct
7 Correct 28 ms 256 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Correct 29 ms 384 KB Output is correct
10 Correct 30 ms 384 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 304 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 29 ms 384 KB Output is correct
23 Correct 27 ms 256 KB Output is correct
24 Correct 27 ms 256 KB Output is correct
25 Correct 28 ms 256 KB Output is correct
26 Correct 27 ms 368 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 27 ms 256 KB Output is correct
29 Correct 27 ms 432 KB Output is correct
30 Correct 27 ms 384 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 360 KB Output is correct
33 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 256 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 28 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 28 ms 256 KB Output is correct
6 Correct 29 ms 384 KB Output is correct
7 Correct 28 ms 256 KB Output is correct
8 Correct 29 ms 364 KB Output is correct
9 Correct 29 ms 384 KB Output is correct
10 Correct 30 ms 384 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 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 304 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 29 ms 384 KB Output is correct
23 Correct 27 ms 256 KB Output is correct
24 Correct 27 ms 256 KB Output is correct
25 Correct 28 ms 256 KB Output is correct
26 Correct 27 ms 368 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 27 ms 256 KB Output is correct
29 Correct 27 ms 432 KB Output is correct
30 Correct 27 ms 384 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 360 KB Output is correct
33 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 29 ms 256 KB Output is correct
17 Correct 28 ms 256 KB Output is correct
18 Correct 28 ms 256 KB Output is correct
19 Correct 29 ms 256 KB Output is correct
20 Correct 28 ms 256 KB Output is correct
21 Correct 29 ms 384 KB Output is correct
22 Correct 28 ms 256 KB Output is correct
23 Correct 29 ms 364 KB Output is correct
24 Correct 29 ms 384 KB Output is correct
25 Correct 30 ms 384 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 256 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 2 ms 304 KB Output is correct
35 Correct 2 ms 256 KB Output is correct
36 Correct 27 ms 256 KB Output is correct
37 Correct 29 ms 384 KB Output is correct
38 Correct 27 ms 256 KB Output is correct
39 Correct 27 ms 256 KB Output is correct
40 Correct 28 ms 256 KB Output is correct
41 Correct 27 ms 368 KB Output is correct
42 Correct 27 ms 256 KB Output is correct
43 Correct 27 ms 256 KB Output is correct
44 Correct 27 ms 432 KB Output is correct
45 Correct 27 ms 384 KB Output is correct
46 Correct 28 ms 256 KB Output is correct
47 Correct 27 ms 360 KB Output is correct
48 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
49 Halted 0 ms 0 KB -