Submission #51514

#TimeUsernameProblemLanguageResultExecution timeMemory
51514spencercomptonBulldozer (JOI17_bulldozer)C++17
5 / 100
60 ms504 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; double ptLineDist(double x1, double y1, double x2, double y2, double px, double py){ double pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); double x, y; if(pd2 == 0){ x = x1; y = y2; } else{ double u = ((px-x1) * (x2 - x1) + (py - y1) * (y2-y1)) / pd2; x = x1 + u * (x2 - x1); y = y1 + u * (y2 - y1); } return (x-px) * (x - px) + (y - py) * (y - py); } int main(){ int n; cin >> n; ll ans = 0LL; ll x[n]; ll y[n]; ll v[n]; for(int i = 0; i<n; i++){ cin >> x[i] >> y[i] >> v[i]; } for(int i = 0; i<n; i++){ ans = max(ans,v[i]); for(int j = i+1; j<n; j++){ ll dx = x[j]-x[i]; ll dy = y[j]-y[i]; //(dy,-dx); vector<pair<double, ll> > li; for(int k = 0; k<n; k++){ bool cross = (y[k]+dx)*(dy-0LL) > (-dx-0LL)*(x[k]-dy); double dist = ptLineDist(0LL, 0LL, dy, -dx, x[k], y[k]); if(cross){ li.push_back(make_pair(dist,v[k])); } else{ li.push_back(make_pair(-dist,v[k])); } } sort(li.begin(),li.end()); ll bestPre = 0LL; ll cur = 0LL; double tol = 1e-9; for(int k = 0; k<n; k++){ if(k>0 && li[k].first-li[k-1].first>tol){ bestPre = min(bestPre,cur); } cur += li[k].second; if(k==n-1 || li[k+1].first-li[k].first>tol){ ans = max(ans,cur-bestPre); } } } } for(int i = 0; i<n; i++){ ans = max(ans,v[i]); for(int j = i+1; j<n; j++){ ll dx = x[j]-x[i]; ll dy = y[j]-y[i]; swap(dx,dy); dx = -dx; //(dy,-dx); vector<pair<double, ll> > li; for(int k = 0; k<n; k++){ bool cross = (y[k]+dx)*(dy-0LL) > (-dx-0LL)*(x[k]-dy); double dist = ptLineDist(0LL, 0LL, dy, -dx, x[k], y[k]); if(cross){ li.push_back(make_pair(dist,v[k])); } else{ li.push_back(make_pair(-dist,v[k])); } } sort(li.begin(),li.end()); ll bestPre = 0LL; ll cur = 0LL; double tol = 1e-9; for(int k = 0; k<n; k++){ if(k>0 && li[k].first-li[k-1].first>tol){ bestPre = min(bestPre,cur); } cur += li[k].second; if(k==n-1 || li[k+1].first-li[k].first>tol){ ans = max(ans,cur-bestPre); } } } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...