Submission #514259

# Submission time Handle Problem Language Result Execution time Memory
514259 2022-01-18T05:56:16 Z amunduzbaev Bulldozer (JOI17_bulldozer) C++14
0 / 100
3 ms 716 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array
#define int long long

long double const eps = 1e-15;

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	vector<ar<int, 3>> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	} sort(a.begin(), a.end());
	
	vector<pair<long double, pair<int, int>>> tt;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i][0] == a[j][0]) continue;
			double slop = (a[j][1] - a[i][1]) * 1. / (a[i][0] - a[j][0]);
			tt.push_back({slop, {i, j}});
		}
	}
	
	vector<long double> b(n);
	vector<int> p(n); iota(p.begin(), p.end(), 0);
	for(int i=0;i<n;i++){
		b[i] = a[i][1] * 1. - (a[i][0] * -2e9);
	}
	
	sort(p.begin(), p.end(), [&](int i, int j){
		return (eps < b[j] - b[i]);
	});
	
	vector<int> pos(n);
	for(int i=0;i<n;i++) pos[p[i]] = i;

	int res = 0;
	sort(tt.begin(), tt.end());
	//~ for(auto x : tt) cout<<x.first<<"\n";
	for(auto s : tt){
		auto [i, j] = s.second;
		
		assert(abs(pos[i] - pos[j]) == 1);
		swap(p[pos[i]], p[pos[j]]);
		swap(pos[i], pos[j]);
		int pref = 0, mn = 0;
		for(int i=0;i<n;i++){
			pref += a[p[i]][2];
			res = max(res, pref - mn);
			mn = min(mn, pref);
		}
	}
	
	cout<<res<<"\n";
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:44:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |   auto [i, j] = s.second;
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 588 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 3 ms 588 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Incorrect 1 ms 204 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -