Submission #521937

# Submission time Handle Problem Language Result Execution time Memory
521937 2022-02-03T13:26:00 Z sofapuden Mobile (BOI12_mobile) C++14
100 / 100
835 ms 35176 KB
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  double k;
  int n; cin >> n >> k;
  vector<pair<double,double>> v(n);
  for(auto &x : v)cin >> x.first >> x.second;
  double l = 0, r = 2e9;
  while((r-l) > 0.0001){
    double mid = (l+r)/2.0;
    vector<double> ran1, ran2;
    for(int i = 0; i < n; ++i){
      if(abs(v[i].second) >= mid)continue;
      double z = sqrt(mid*mid-v[i].second*v[i].second);
      while(ran1.size() && max(v[i].first-z,0.0) < ran1.back()){
        ran1.pop_back();
        ran2.pop_back();
      }
      if(ran1.empty() || v[i].first+z > ran2.back()){
        if(ran1.size() && v[i].first-z < ran2.back()){
          ran1.back() = max(0.0,min(v[i].first-z,ran1.back()));
          ran2.back() = min(v[i].first+z,k);
        }
        else{
          ran1.push_back(max(min(v[i].first-z,k),0.0));
          ran2.push_back(min(max(v[i].first+z,0.0),k));
        }
      }
      if(ran1.back() == ran2.back()){
        ran1.pop_back();
        ran2.pop_back();
      }
    }
    if(ran1.empty() || ran1[0] != 0 || ran2.back() != k){
      l = mid;
      continue;
    }
    bool ok = 1;
    for(int i = 1; i < (int)ran1.size(); ++i){
      if(ran2[i-1] < ran1[i]){
        ok = 0;
        break;
      }
      if(ran2[i] == k)break;
    }
    if(ok){
      r = mid;
    }
    else{
      l = mid;
    }
  }
  printf("%.4f\n", l);

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 4 ms 388 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 7 ms 332 KB Output is correct
3 Correct 6 ms 316 KB Output is correct
4 Correct 5 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 396 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 4 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 1732 KB Output is correct
2 Correct 57 ms 1764 KB Output is correct
3 Correct 35 ms 1348 KB Output is correct
4 Correct 52 ms 1740 KB Output is correct
5 Correct 28 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1788 KB Output is correct
2 Correct 40 ms 2116 KB Output is correct
3 Correct 50 ms 2592 KB Output is correct
4 Correct 64 ms 2748 KB Output is correct
5 Correct 52 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1820 KB Output is correct
2 Correct 65 ms 1740 KB Output is correct
3 Correct 66 ms 1884 KB Output is correct
4 Correct 69 ms 2320 KB Output is correct
5 Correct 51 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 2116 KB Output is correct
2 Correct 76 ms 3248 KB Output is correct
3 Correct 63 ms 2888 KB Output is correct
4 Correct 70 ms 3776 KB Output is correct
5 Correct 58 ms 3016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 2000 KB Output is correct
2 Correct 73 ms 2116 KB Output is correct
3 Correct 72 ms 2180 KB Output is correct
4 Correct 66 ms 3780 KB Output is correct
5 Correct 57 ms 3144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 8400 KB Output is correct
2 Correct 380 ms 8284 KB Output is correct
3 Correct 386 ms 8396 KB Output is correct
4 Correct 307 ms 8388 KB Output is correct
5 Correct 313 ms 14908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 391 ms 8396 KB Output is correct
2 Correct 433 ms 8488 KB Output is correct
3 Correct 329 ms 8484 KB Output is correct
4 Correct 338 ms 8384 KB Output is correct
5 Correct 294 ms 8396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 459 ms 9960 KB Output is correct
2 Correct 567 ms 9956 KB Output is correct
3 Correct 460 ms 9948 KB Output is correct
4 Correct 383 ms 9952 KB Output is correct
5 Correct 370 ms 9896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 492 ms 9948 KB Output is correct
2 Correct 472 ms 9940 KB Output is correct
3 Correct 402 ms 9960 KB Output is correct
4 Correct 374 ms 9940 KB Output is correct
5 Correct 357 ms 10052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 499 ms 11524 KB Output is correct
2 Correct 596 ms 11528 KB Output is correct
3 Correct 547 ms 11468 KB Output is correct
4 Correct 433 ms 11472 KB Output is correct
5 Correct 428 ms 20312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 585 ms 11592 KB Output is correct
2 Correct 567 ms 11520 KB Output is correct
3 Correct 462 ms 19656 KB Output is correct
4 Correct 479 ms 24656 KB Output is correct
5 Correct 444 ms 21316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 572 ms 13088 KB Output is correct
2 Correct 646 ms 13096 KB Output is correct
3 Correct 660 ms 24356 KB Output is correct
4 Correct 559 ms 28464 KB Output is correct
5 Correct 501 ms 24004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 625 ms 13004 KB Output is correct
2 Correct 639 ms 13124 KB Output is correct
3 Correct 527 ms 13088 KB Output is correct
4 Correct 504 ms 12996 KB Output is correct
5 Correct 471 ms 13088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 711 ms 16220 KB Output is correct
2 Correct 811 ms 31564 KB Output is correct
3 Correct 787 ms 30556 KB Output is correct
4 Correct 653 ms 35176 KB Output is correct
5 Correct 597 ms 29644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 791 ms 16068 KB Output is correct
2 Correct 835 ms 16224 KB Output is correct
3 Correct 713 ms 16220 KB Output is correct
4 Correct 654 ms 15968 KB Output is correct
5 Correct 586 ms 16228 KB Output is correct