답안 #101013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101013 2019-03-16T04:09:29 Z autumn_eel Bulldozer (JOI17_bulldozer) C++14
20 / 100
29 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();
	rep(i,n){
		scanf("%lf%lf%lld",&p[i].x,&p[i].y,&w[i]);
	}
	if(n==1){
		cout<<max(w[0],0LL)<<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:59: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:67:3: note: in expansion of macro 'rep'
   rep(i,v.size()){
   ^~~
bulldozer.cpp:43: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 Incorrect 17 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 360 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 29 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 29 ms 256 KB Output is correct
6 Correct 28 ms 256 KB Output is correct
7 Correct 29 ms 404 KB Output is correct
8 Correct 28 ms 256 KB Output is correct
9 Correct 28 ms 384 KB Output is correct
10 Correct 28 ms 256 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 256 KB Output is correct
14 Correct 4 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 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 27 ms 376 KB Output is correct
23 Correct 27 ms 384 KB Output is correct
24 Correct 28 ms 360 KB Output is correct
25 Correct 27 ms 256 KB Output is correct
26 Correct 27 ms 376 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 28 ms 256 KB Output is correct
29 Correct 26 ms 360 KB Output is correct
30 Correct 27 ms 360 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 360 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 29 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 29 ms 256 KB Output is correct
6 Correct 28 ms 256 KB Output is correct
7 Correct 29 ms 404 KB Output is correct
8 Correct 28 ms 256 KB Output is correct
9 Correct 28 ms 384 KB Output is correct
10 Correct 28 ms 256 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 256 KB Output is correct
14 Correct 4 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 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 27 ms 376 KB Output is correct
23 Correct 27 ms 384 KB Output is correct
24 Correct 28 ms 360 KB Output is correct
25 Correct 27 ms 256 KB Output is correct
26 Correct 27 ms 376 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 28 ms 256 KB Output is correct
29 Correct 26 ms 360 KB Output is correct
30 Correct 27 ms 360 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 384 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 28 ms 360 KB Output is correct
2 Correct 28 ms 256 KB Output is correct
3 Correct 29 ms 256 KB Output is correct
4 Correct 29 ms 256 KB Output is correct
5 Correct 29 ms 256 KB Output is correct
6 Correct 28 ms 256 KB Output is correct
7 Correct 29 ms 404 KB Output is correct
8 Correct 28 ms 256 KB Output is correct
9 Correct 28 ms 384 KB Output is correct
10 Correct 28 ms 256 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 256 KB Output is correct
14 Correct 4 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 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 27 ms 256 KB Output is correct
22 Correct 27 ms 376 KB Output is correct
23 Correct 27 ms 384 KB Output is correct
24 Correct 28 ms 360 KB Output is correct
25 Correct 27 ms 256 KB Output is correct
26 Correct 27 ms 376 KB Output is correct
27 Correct 27 ms 256 KB Output is correct
28 Correct 28 ms 256 KB Output is correct
29 Correct 26 ms 360 KB Output is correct
30 Correct 27 ms 360 KB Output is correct
31 Correct 28 ms 256 KB Output is correct
32 Correct 27 ms 384 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 Incorrect 17 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -