Submission #1109878

#TimeUsernameProblemLanguageResultExecution timeMemory
1109878ChottuFMobile (BOI12_mobile)C++17
0 / 100
452 ms70320 KiB
#include <bits/stdc++.h> using namespace std; inline long double f(pair<long double,long double> a, pair<long double,long double> b){ return ((a.first-b.first)*(a.first-b.first)) + ((a.second-b.second)*(a.second-b.second)); } signed main(){ long double n,l; cin >> n >> l; stack<pair<long double,long double>> s; for (int i = 0; i<n; i++){ long double a,b; cin >> a >> b; if (s.empty()){ s.push({a,b}); } else{ while (true){ pair<long double,long double> d = s.top(); if (d.second > b){ //take him out s.pop(); } else{ break; } } s.push({a,b}); } } vector<pair<long double,long double>> vec; while (!s.empty()){ vec.push_back(s.top()); s.pop(); } reverse(vec.begin(),vec.end()); long double mx = 0; for (int i = 0; i<vec.size()-1; i++){ auto [x1, y1] = vec[i]; auto [x2, y2] = vec[i+1]; long double m = (y1-y2)/(x1-x2); const long double NEGONE = -1; long double newm = NEGONE/m; long double a = (x1+x2)/2; long double b = (y1+y2)/2; long double c = b - (newm*a); //y = newm * x + c long double newx = -c/newm; mx = max(mx, f({0,newx},vec[i])); } int sz = vec.size(); mx = max(mx, vec[0].first*vec[0].first + vec[0].second*vec[0].second); mx = max(mx, (vec[sz-1].first-l)*(vec[sz-1].first-l) + vec[0].second + vec[0].second); cout << sqrtl(mx); return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i<vec.size()-1; i++){
      |                     ~^~~~~~~~~~~~~
#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...