Submission #970788

# Submission time Handle Problem Language Result Execution time Memory
970788 2024-04-27T09:00:37 Z hihihihaw Mobile (BOI12_mobile) C++17
100 / 100
735 ms 32192 KB
#pragma GCC optimize("O3,unroll-loops")    
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define pii pair<int,int>
#define sz(v) (int)v.size()
#define fi first
#define se second
#define INF 1223372036854775807
#define MOD 1000000007
#define cint(x) int x;cin>>x;
#define cinarr(a,n) int a[n];for (int i=0;i<n;i++) cin>>a[i];
#define coutarr(a) for (auto d:a)cout<<d<<" "; cout<<endl;
#define coutarrD(a) for (auto d:a) cout<<d.fi<<","<<d.se<<" "; cout<<endl;
#define AYBERK_SARICA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define ld long double
#define mid (start+end)/2
 
int t=1;
int interactive=0;
int usaco=0;
int testCase=0;
int n,k;
pair<ld,ld> v[1000023];
void solve(){
    cin>>n>>k;
    for (int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        v[i]={x,y};
    }
    ld l=0,r=1500000000;
    while (r-l>0.001){
        ld m=(l+r)/2;
        ld b=0;
        ld x=m;
        for (int i=0;i<n;i++){
            if (x*x-v[i].se*v[i].se>0){
                ld y=sqrt(x*x-v[i].se*v[i].se);
                if (v[i].fi+y<0 || v[i].fi-y>k) continue;
                ld a1=max(v[i].fi-y,(ld)0),b1=min(v[i].fi+y,(ld)k);
                if (a1<=b) b=max(b,b1);
            }
        }
        if (b==k) r=m;
        else l=m;
    }
    cout<<setprecision(15)<<l<<endl;
    
 
    
    
    
 
    
    
 
 
    
    
    
    
    
 
    
 
    
    
 
    
 
    
}
 
 
 
 
 
    
 
 
 
 
 
int32_t main(){
    AYBERK_SARICA;
    if (usaco){
        freopen("socdist.in", "r", stdin);
        freopen("socdist.out", "w", stdout);
    }
    if (!interactive){
    #ifdef Local
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        //freopen("wormsort.out", "w", stdout);
    #endif
    }
    if (t==1) solve();
    else{
        cin>>t;
        while (t--){testCase++;solve();}
    }
    
        
    return 0;
}

Compilation message

mobile.cpp: In function 'int32_t main()':
mobile.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |         freopen("socdist.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen("socdist.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Correct 4 ms 604 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 4 ms 604 KB Output is correct
3 Correct 4 ms 768 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 604 KB Output is correct
2 Correct 4 ms 608 KB Output is correct
3 Correct 4 ms 540 KB Output is correct
4 Correct 3 ms 608 KB Output is correct
5 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 4708 KB Output is correct
2 Correct 73 ms 4732 KB Output is correct
3 Correct 37 ms 2708 KB Output is correct
4 Correct 41 ms 4712 KB Output is correct
5 Correct 29 ms 2728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 4700 KB Output is correct
2 Correct 42 ms 2652 KB Output is correct
3 Correct 43 ms 4732 KB Output is correct
4 Correct 44 ms 4688 KB Output is correct
5 Correct 45 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 4748 KB Output is correct
2 Correct 58 ms 4700 KB Output is correct
3 Correct 58 ms 4732 KB Output is correct
4 Correct 56 ms 4476 KB Output is correct
5 Correct 51 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 4484 KB Output is correct
2 Correct 75 ms 4748 KB Output is correct
3 Correct 66 ms 4732 KB Output is correct
4 Correct 58 ms 4728 KB Output is correct
5 Correct 58 ms 4728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 4748 KB Output is correct
2 Correct 77 ms 4732 KB Output is correct
3 Correct 69 ms 4752 KB Output is correct
4 Correct 54 ms 4700 KB Output is correct
5 Correct 54 ms 4732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 366 ms 17040 KB Output is correct
2 Correct 368 ms 17288 KB Output is correct
3 Correct 363 ms 17020 KB Output is correct
4 Correct 294 ms 17032 KB Output is correct
5 Correct 296 ms 17028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 366 ms 17048 KB Output is correct
2 Correct 366 ms 17016 KB Output is correct
3 Correct 335 ms 17020 KB Output is correct
4 Correct 255 ms 17020 KB Output is correct
5 Correct 267 ms 17028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 447 ms 21144 KB Output is correct
2 Correct 472 ms 21392 KB Output is correct
3 Correct 437 ms 21152 KB Output is correct
4 Correct 393 ms 21140 KB Output is correct
5 Correct 333 ms 21140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 448 ms 21136 KB Output is correct
2 Correct 418 ms 21400 KB Output is correct
3 Correct 391 ms 21076 KB Output is correct
4 Correct 326 ms 21384 KB Output is correct
5 Correct 325 ms 21144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 492 ms 23392 KB Output is correct
2 Correct 507 ms 23380 KB Output is correct
3 Correct 492 ms 23200 KB Output is correct
4 Correct 368 ms 23380 KB Output is correct
5 Correct 387 ms 23124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 496 ms 23168 KB Output is correct
2 Correct 465 ms 23648 KB Output is correct
3 Correct 448 ms 23196 KB Output is correct
4 Correct 370 ms 23196 KB Output is correct
5 Correct 384 ms 23444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 552 ms 27220 KB Output is correct
2 Correct 564 ms 27216 KB Output is correct
3 Correct 568 ms 27300 KB Output is correct
4 Correct 418 ms 27220 KB Output is correct
5 Correct 448 ms 27232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 581 ms 27476 KB Output is correct
2 Correct 520 ms 27216 KB Output is correct
3 Correct 514 ms 27272 KB Output is correct
4 Correct 426 ms 27528 KB Output is correct
5 Correct 430 ms 27216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 696 ms 31884 KB Output is correct
2 Correct 735 ms 31756 KB Output is correct
3 Correct 707 ms 31824 KB Output is correct
4 Correct 524 ms 31572 KB Output is correct
5 Correct 574 ms 31756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 714 ms 32192 KB Output is correct
2 Correct 642 ms 31756 KB Output is correct
3 Correct 644 ms 31756 KB Output is correct
4 Correct 535 ms 31568 KB Output is correct
5 Correct 556 ms 31620 KB Output is correct