답안 #198646

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198646 2020-01-27T06:20:51 Z TAISA_ Bulldozer (JOI17_bulldozer) C++14
0 / 100
10 ms 764 KB
#include <bits/stdc++.h>
#define mp make_pair
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using vi=vector<ll>;
using P=pair<int,int>;
using db=long double;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	vector<ll> x(n),y(n),w(n);
	vector<pair<P,int>> ps;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>w[i];
		ps.push_back(mp(P(y[i],x[i]),i));
	}
	vector<pair<db,P>> v;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j){
				continue;
			}
			if(y[i]>y[j]){
				continue;
			}
			if(y[i]==y[j]&&x[i]>x[j]){
				continue;
			}
			db th=atan2l(y[j]-y[i],x[j]-x[i]);
			v.push_back(mp(th,P(i,j)));
		}
	}
	sort(all(v));
	sort(all(ps));
	vector<int> s,idx(n);
	for(int i=0;i<n;i++){
		s.push_back(ps[i].second);
		idx[ps[i].second]=i;
	}
	ll res=0;
	for(int i=0;i<v.size();i++){
		int p=v[i].second.first,q=v[i].second.second;
		swap(s[idx[p]],s[idx[q]]);
		swap(idx[p],idx[q]);
		vector<ll> sum(n+1);
		for(int j=0;j<n;j++){
			sum[j+1]=sum[j]+w[s[j]];
		}
		ll mi=0;
		for(int j=1;j<=n;j++){
			res=max(res,sum[j]-mi);
			mi=min(mi,sum[j]);
		}
	}
	cout<<res<<endl;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:43: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 8 ms 760 KB Output is correct
2 Correct 9 ms 760 KB Output is correct
3 Correct 8 ms 764 KB Output is correct
4 Correct 9 ms 760 KB Output is correct
5 Correct 10 ms 760 KB Output is correct
6 Correct 9 ms 760 KB Output is correct
7 Correct 9 ms 760 KB Output is correct
8 Correct 8 ms 760 KB Output is correct
9 Correct 10 ms 760 KB Output is correct
10 Correct 8 ms 632 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Incorrect 5 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 760 KB Output is correct
2 Correct 9 ms 760 KB Output is correct
3 Correct 8 ms 764 KB Output is correct
4 Correct 9 ms 760 KB Output is correct
5 Correct 10 ms 760 KB Output is correct
6 Correct 9 ms 760 KB Output is correct
7 Correct 9 ms 760 KB Output is correct
8 Correct 8 ms 760 KB Output is correct
9 Correct 10 ms 760 KB Output is correct
10 Correct 8 ms 632 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Incorrect 5 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 760 KB Output is correct
2 Correct 9 ms 760 KB Output is correct
3 Correct 8 ms 764 KB Output is correct
4 Correct 9 ms 760 KB Output is correct
5 Correct 10 ms 760 KB Output is correct
6 Correct 9 ms 760 KB Output is correct
7 Correct 9 ms 760 KB Output is correct
8 Correct 8 ms 760 KB Output is correct
9 Correct 10 ms 760 KB Output is correct
10 Correct 8 ms 632 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Incorrect 5 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -