Submission #638910

#TimeUsernameProblemLanguageResultExecution timeMemory
638910endyMobile (BOI12_mobile)C++17
0 / 100
597 ms39592 KiB
#include <bits/stdc++.h> using namespace std; int n, l, d; vector < pair<double,double> > coord; vector < pair<double, pair<double, int> > > dist; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> l; for(int i=0 ; i<n ; i++){ double a, b; cin >> a >> b; coord.push_back(make_pair(a,b)); double dmin, dmax; if(a < 0){ dmin = (a*a)+(b*b); dmax = ((a+l)*(a+l))+(b*b); }else if(a >= 0 and a <=l){ dmin = b; if(a <= l/2) dmax = ((l-a)*(l-a))+(b*b); else dmax = (a*a)+(b*b); }else if(a > l){ dmin = ((a-l)*(a-l))+(b*b); dmax = (a*a)+(b*b); } dist.push_back(make_pair(dmin, make_pair(dmax, i))); } sort(dist.begin(), dist.end()); double t = dist[n-2].second.second, u = dist[n-1].second.second; double ax = coord[t].first, ay = coord[t].second, bx = coord[u].first, by = coord[u].second; double T = (ax*ax), U = (ay*ay), V = (bx*bx), W = (by*by); double centro = (U+V-W-T)/(2*(bx-ax)); if(centro > bx){ d = (by*by)+((centro-bx)*(centro-bx)); }else{ d = (by*by)+((bx-centro)*(bx-centro)); } cout << sqrt(d) << 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...
#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...
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...