Submission #305265

#TimeUsernameProblemLanguageResultExecution timeMemory
305265oleksgMobile (BOI12_mobile)C++14
0 / 100
1091 ms39152 KiB
#include <fstream> #include <string> #include <iostream> #include <math.h> #include <algorithm> #include<bits/stdc++.h> #include <vector> using namespace std; double n, l; vector<pair<double, double>> points; bool ok(double cur){ vector<pair<double, double>> segs; for (long long x = 0; x < points.size(); x++){ double curx = points[x].first; double cury = abs(points[x].second); if (cur >= cury){ double xintervals = sqrt(cur * cur - cury * cury); double minx = curx - xintervals; double maxx = curx + xintervals; if (minx <= l && maxx >= 0 && cur >= cury){ segs.push_back(make_pair(minx, maxx)); } } } sort(segs.begin(), segs.end()); if (segs[0].first > 0){ return false; } double curx = 0; for (long long x = 0; x < segs.size(); x++){ if (segs[x].second > curx){ if (segs[x].first <= curx){ curx = segs[x].second; } else{ return false; } } } if (curx < l){ return false; } return true; } int main(){ double one, two; cin >> n >> l; for (int x = 0; x < n; x++){ cin >> one >> two; points.push_back(make_pair(one, two)); } double mi = 0.0; double ma = 10000000000; //cout << ok(658); while(ma - mi > 0.0005){ double cur = (mi + ma) / 2.0; if (ok(cur)){ ma = cur; } else{ mi = cur + 0.0005; } } printf("%.7g", ma); }

Compilation message (stderr)

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:15:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (long long x = 0; x < points.size(); x++){
      |                           ~~^~~~~~~~~~~~~~~
mobile.cpp:32:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (long long x = 0; x < segs.size(); x++){
      |                           ~~^~~~~~~~~~~~~
#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...