Submission #494137

# Submission time Handle Problem Language Result Execution time Memory
494137 2021-12-14T12:45:22 Z PikaQ Mobile (BOI12_mobile) C++17
8 / 100
865 ms 16148 KB
#include<bits/stdc++.h>
#define int ll
#define forn(i,n) for(int i=0;i<(n);i++)
#define Forn(i,n) for(int i=1;i<=(n);i++)
#define ll long long
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define rz resize
#define all(p) p.begin(),p.end()
#define alr(p,q) p+1,p+q+1
#define ull unsigned long long
#define st0(p) memset((p),0,sizeof(p))
#define T(x) ((x)%2 ? s[(x)/2] : '.')
#define lowb(x) x&-x
#define ls(x) (x)*2
#define rs(x) (x)*2+1
using namespace std;

inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}

void debug() {cout << endl;}
template <class T, class ...U> void debug(T a, U ... b) { cout << a << " "; debug(b...);}
// template <class T> int max(T a, T ... b) { cout << a << " "; debug(b...);}
const int INF = 1e9+7;
const double eps = 1e-7;
const int N = 8e2+9;
int n;
double L;
#define pdd pair<double,double> 
vector<pdd> p;


bool check(double R){
  stack<pdd> sk;
  double cur = 0;
  for(auto &i : p){
    double dy = abs(i.S);
    if(dy > R) continue;
    double d = sqrt(R*R - dy*dy);
    double l = i.F -d,r = i.F +d;
    l = max((double)0,l),r = min(L,r);
    if(l <= cur) cur = max(cur,r);
  }
  return cur >= L;
}

void solve(){
  cin >> n >> L;
  p.rz(n);
  forn(i,n) cin >> p[i].F >> p[i].S;
  sort(all(p));
  double lo = 0,hi = 1e18;
  int cnt = 1e5+1;  
  while(hi - lo > 1e-7){
    double mid = (lo+hi)/2;
    if(check(mid)) hi = mid;
    else lo = mid;
  }
  cout << hi << '\n';
}     



signed main(){
  // USACO("angry");
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);

  // int t;
  // cin >> t;
  // while(t--)
    solve();
  return 0;
}

Compilation message

mobile.cpp: In function 'void solve()':
mobile.cpp:65:7: warning: unused variable 'cnt' [-Wunused-variable]
   65 |   int cnt = 1e5+1;
      |       ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 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 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 324 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Incorrect 3 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Incorrect 4 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Incorrect 4 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 444 KB Output is correct
2 Incorrect 5 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 60 ms 1632 KB Output is correct
2 Incorrect 80 ms 1716 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1612 KB Output is correct
2 Correct 44 ms 1568 KB Output is correct
3 Incorrect 56 ms 1824 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1740 KB Output is correct
2 Incorrect 87 ms 1612 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 1992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 1996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 381 ms 8288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 379 ms 8388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 403 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 469 ms 9840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 458 ms 11472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 544 ms 11392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 566 ms 12960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 639 ms 12996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 700 ms 16092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 865 ms 16148 KB Output isn't correct
2 Halted 0 ms 0 KB -