Submission #970782

# Submission time Handle Problem Language Result Execution time Memory
970782 2024-04-27T08:53:28 Z hihihihaw Mobile (BOI12_mobile) C++17
80 / 100
1000 ms 63068 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){
        pair<ld,ld> z[n];
        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;
                z[i]={max(v[i].fi-y,(ld)0),min(v[i].fi+y,(ld)k)};
                if (z[i].fi<=b) b=max(b,z[i].se);
            }
        }
        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: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.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen("socdist.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 600 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 7 ms 600 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 604 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 5 ms 604 KB Output is correct
5 Correct 5 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 7028 KB Output is correct
2 Correct 102 ms 7108 KB Output is correct
3 Correct 62 ms 4340 KB Output is correct
4 Correct 74 ms 7248 KB Output is correct
5 Correct 52 ms 4184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 6992 KB Output is correct
2 Correct 71 ms 4700 KB Output is correct
3 Correct 82 ms 7256 KB Output is correct
4 Correct 76 ms 6992 KB Output is correct
5 Correct 84 ms 7268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 7256 KB Output is correct
2 Correct 108 ms 7292 KB Output is correct
3 Correct 103 ms 7260 KB Output is correct
4 Correct 88 ms 7804 KB Output is correct
5 Correct 89 ms 7252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 8020 KB Output is correct
2 Correct 128 ms 7760 KB Output is correct
3 Correct 117 ms 7844 KB Output is correct
4 Correct 91 ms 7772 KB Output is correct
5 Correct 100 ms 7848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 7764 KB Output is correct
2 Correct 129 ms 7764 KB Output is correct
3 Correct 118 ms 7852 KB Output is correct
4 Correct 92 ms 7760 KB Output is correct
5 Correct 96 ms 7824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 639 ms 32680 KB Output is correct
2 Correct 651 ms 32636 KB Output is correct
3 Correct 649 ms 32684 KB Output is correct
4 Correct 467 ms 32684 KB Output is correct
5 Correct 495 ms 32592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 654 ms 32592 KB Output is correct
2 Correct 596 ms 32688 KB Output is correct
3 Correct 607 ms 32680 KB Output is correct
4 Correct 468 ms 32596 KB Output is correct
5 Correct 490 ms 32676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 777 ms 39920 KB Output is correct
2 Correct 788 ms 40060 KB Output is correct
3 Correct 788 ms 39916 KB Output is correct
4 Correct 557 ms 39764 KB Output is correct
5 Correct 596 ms 39916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 824 ms 39792 KB Output is correct
2 Correct 687 ms 39800 KB Output is correct
3 Correct 750 ms 39912 KB Output is correct
4 Correct 561 ms 40060 KB Output is correct
5 Correct 580 ms 39924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 890 ms 45192 KB Output is correct
2 Correct 932 ms 45140 KB Output is correct
3 Correct 911 ms 44880 KB Output is correct
4 Correct 656 ms 45104 KB Output is correct
5 Correct 697 ms 45096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 934 ms 45104 KB Output is correct
2 Correct 785 ms 45104 KB Output is correct
3 Correct 843 ms 45100 KB Output is correct
4 Correct 651 ms 45140 KB Output is correct
5 Correct 680 ms 44932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 52360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 52128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1040 ms 62800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1026 ms 63068 KB Time limit exceeded
2 Halted 0 ms 0 KB -