Submission #206075

# Submission time Handle Problem Language Result Execution time Memory
206075 2020-03-02T07:31:47 Z TAISA_ Bulldozer (JOI17_bulldozer) C++14
55 / 100
812 ms 33616 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{
	struct T{
		ll l,r,sum,val;
	};
	T merge(T &a,T &b){
		T res;
		res.l=max(a.l,a.sum+b.l);
		res.r=max(b.r,a.r+b.sum);
		res.sum=a.sum+b.sum;
		res.val=max({a.val,b.val,a.r+b.l});
		return res;
	}
	int n;
	vector<T> dat;
	segtree(int n_){
		n=1;
		while(n<n_)n<<=1;
		dat.resize(2*n,T{0,0,0,0});
	}
	void upd(int k,ll x){
		T to=T{max(x,0LL),max(x,0LL),x,max(x,0LL)};
		k+=n;
		dat[k]=to;
		k>>=1;
		while(k>0){
			dat[k]=merge(dat[k<<1],dat[k<<1|1]);
			k>>=1;
		}
	}
	inline ll get(){
		return dat[1].val;
	}
};
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	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:75:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size();i++){
              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 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 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 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 504 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 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 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 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 504 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Correct 797 ms 33448 KB Output is correct
34 Correct 772 ms 33468 KB Output is correct
35 Correct 790 ms 33404 KB Output is correct
36 Correct 803 ms 33468 KB Output is correct
37 Correct 808 ms 33596 KB Output is correct
38 Correct 808 ms 33468 KB Output is correct
39 Correct 812 ms 33468 KB Output is correct
40 Correct 783 ms 33468 KB Output is correct
41 Correct 789 ms 33468 KB Output is correct
42 Correct 801 ms 33616 KB Output is correct
43 Correct 764 ms 33472 KB Output is correct
44 Correct 768 ms 33596 KB Output is correct
45 Correct 761 ms 33596 KB Output is correct
46 Correct 763 ms 33468 KB Output is correct
47 Correct 769 ms 33500 KB Output is correct
48 Correct 769 ms 33528 KB Output is correct
49 Correct 773 ms 33468 KB Output is correct
50 Correct 770 ms 33476 KB Output is correct
51 Correct 768 ms 33468 KB Output is correct
52 Correct 789 ms 33468 KB Output is correct
53 Correct 766 ms 33472 KB Output is correct
54 Correct 752 ms 33596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Output is correct
2 Correct 6 ms 504 KB Output is correct
3 Correct 6 ms 504 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 6 ms 504 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 6 ms 504 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 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 4 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 380 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 504 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 7 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Correct 797 ms 33448 KB Output is correct
34 Correct 772 ms 33468 KB Output is correct
35 Correct 790 ms 33404 KB Output is correct
36 Correct 803 ms 33468 KB Output is correct
37 Correct 808 ms 33596 KB Output is correct
38 Correct 808 ms 33468 KB Output is correct
39 Correct 812 ms 33468 KB Output is correct
40 Correct 783 ms 33468 KB Output is correct
41 Correct 789 ms 33468 KB Output is correct
42 Correct 801 ms 33616 KB Output is correct
43 Correct 764 ms 33472 KB Output is correct
44 Correct 768 ms 33596 KB Output is correct
45 Correct 761 ms 33596 KB Output is correct
46 Correct 763 ms 33468 KB Output is correct
47 Correct 769 ms 33500 KB Output is correct
48 Correct 769 ms 33528 KB Output is correct
49 Correct 773 ms 33468 KB Output is correct
50 Correct 770 ms 33476 KB Output is correct
51 Correct 768 ms 33468 KB Output is correct
52 Correct 789 ms 33468 KB Output is correct
53 Correct 766 ms 33472 KB Output is correct
54 Correct 752 ms 33596 KB Output is correct
55 Correct 790 ms 33468 KB Output is correct
56 Correct 780 ms 33468 KB Output is correct
57 Correct 787 ms 33464 KB Output is correct
58 Correct 787 ms 33468 KB Output is correct
59 Correct 791 ms 33468 KB Output is correct
60 Correct 804 ms 33472 KB Output is correct
61 Correct 779 ms 33460 KB Output is correct
62 Correct 783 ms 33468 KB Output is correct
63 Correct 771 ms 33596 KB Output is correct
64 Correct 792 ms 33468 KB Output is correct
65 Incorrect 793 ms 33468 KB Output isn't correct
66 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -