답안 #206074

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206074 2020-03-02T07:26:24 Z TAISA_ Bulldozer (JOI17_bulldozer) C++14
20 / 100
8 ms 760 KB
#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define eb emplace_back
using namespace std;
using ll=long long;
using P=pair<int,int>;
using C=complex<double>;
void chmax(ll &a,ll b){a=max(a,b);}
void chmin(ll &a,ll b){a=min(a,b);}
struct segtree{
	int n;
	vector<ll> dat;
	segtree(int n):n(n){
		dat.resize(n);
	}
	void upd(int k,ll x){
		dat[k]=x;
	}
	ll get(){
		ll sum=0,mi=0,res=0;
		for(int i=0;i<n;i++){
			sum+=dat[i];
			chmax(res,sum-mi);
			chmin(mi,sum);
		}
		return res;
	}
};
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	assert(n<=100);
	vector<double> x(n),y(n);
	vector<ll> w(n);
	vector<pair<double,P>> v;
	vector<P> ps(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>w[i];
		ps[i].first=y[i];
		ps[i].second=i;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			double t=atan2(y[j]-y[i],x[j]-x[i]);
			if(t>=0){
				v.eb(t,P(i,j));
			}
		}
	}
	sort(all(v));
	sort(all(ps));
	reverse(all(ps));
	segtree seg(n);
	vector<int> pos(n);
	for(int i=0;i<n;i++){
		seg.upd(i,w[ps[i].second]);
		pos[ps[i].second]=i;
	}
	ll res=seg.get();
	for(int i=0;i<v.size();i++){
		int l=v[i].second.first,r=v[i].second.second;
		swap(pos[l],pos[r]);
		seg.upd(pos[l],w[l]);
		seg.upd(pos[r],w[r]);
		chmax(res,seg.get());
	}
	cout<<res<<'\n';
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:62:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 504 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 8 ms 504 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
5 Correct 7 ms 632 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 6 ms 548 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 8 ms 504 KB Output is correct
10 Correct 7 ms 508 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 7 ms 504 KB Output is correct
22 Correct 7 ms 504 KB Output is correct
23 Correct 7 ms 504 KB Output is correct
24 Correct 7 ms 508 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 632 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 504 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 8 ms 504 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
5 Correct 7 ms 632 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 6 ms 548 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 8 ms 504 KB Output is correct
10 Correct 7 ms 508 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 7 ms 504 KB Output is correct
22 Correct 7 ms 504 KB Output is correct
23 Correct 7 ms 504 KB Output is correct
24 Correct 7 ms 508 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 632 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 504 KB Output is correct
2 Correct 7 ms 504 KB Output is correct
3 Correct 8 ms 504 KB Output is correct
4 Correct 8 ms 504 KB Output is correct
5 Correct 7 ms 632 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 6 ms 548 KB Output is correct
8 Correct 7 ms 504 KB Output is correct
9 Correct 8 ms 504 KB Output is correct
10 Correct 7 ms 508 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 7 ms 504 KB Output is correct
22 Correct 7 ms 504 KB Output is correct
23 Correct 7 ms 504 KB Output is correct
24 Correct 7 ms 508 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 632 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 7 ms 504 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -