Submission #970774

# Submission time Handle Problem Language Result Execution time Memory
970774 2024-04-27T08:38:24 Z hihihihaw Mobile (BOI12_mobile) C++17
65 / 100
1000 ms 71368 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;
ld v[1000023][2];
bool f(ld x){
    ld z[n][2]={};
    for (int i=0;i<n;i++){
        if (x-v[i][1]>0){
            ld y=sqrt(x*x-v[i][1]*v[i][1]);
            if (v[i][0]+y<0 || v[i][0]-y>k) continue;
            z[i][0]=max(v[i][0]-y,(ld)0);
            z[i][1]=min(v[i][0]+y,(ld)k);
        }
    }
    ld b=0;
    for (int i=0;i<n;i++){
        if (z[i][0]<=b){
            b=max(z[i][1],b);
        }
    }
    if (b!=k) return false;
    return true;
}

void solve(){
    cin>>n>>k;
    for (int i=0;i<n;i++){
        ld x,y;
        cin>>x>>y;
        v[i][0]=x;
        v[i][1]=y;
    }
    ld l=0,r=1500000000;
    int y=42;
    while (y--){
        ld m=(l+r)/2;
        if (f(m)) 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:103:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  103 |         freopen("socdist.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:104:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |         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 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 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 4 ms 604 KB Output is correct
2 Correct 3 ms 652 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 728 KB Output is correct
2 Correct 6 ms 600 KB Output is correct
3 Correct 5 ms 604 KB Output is correct
4 Correct 6 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 856 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 5 ms 604 KB Output is correct
4 Correct 6 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 6 ms 604 KB Output is correct
3 Correct 5 ms 728 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 6 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 7812 KB Output is correct
2 Correct 83 ms 7764 KB Output is correct
3 Correct 55 ms 4836 KB Output is correct
4 Correct 118 ms 7680 KB Output is correct
5 Correct 53 ms 4620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 7932 KB Output is correct
2 Correct 97 ms 5468 KB Output is correct
3 Correct 122 ms 8184 KB Output is correct
4 Correct 117 ms 7972 KB Output is correct
5 Correct 131 ms 8312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 7980 KB Output is correct
2 Correct 89 ms 8060 KB Output is correct
3 Correct 85 ms 8020 KB Output is correct
4 Correct 158 ms 9044 KB Output is correct
5 Correct 116 ms 8276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 8872 KB Output is correct
2 Correct 108 ms 8784 KB Output is correct
3 Correct 98 ms 8532 KB Output is correct
4 Correct 162 ms 9296 KB Output is correct
5 Correct 142 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 9120 KB Output is correct
2 Correct 109 ms 8784 KB Output is correct
3 Correct 99 ms 8616 KB Output is correct
4 Correct 159 ms 9040 KB Output is correct
5 Correct 140 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 585 ms 35164 KB Output is correct
2 Correct 581 ms 36844 KB Output is correct
3 Correct 570 ms 36524 KB Output is correct
4 Correct 808 ms 37716 KB Output is correct
5 Correct 734 ms 36268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 593 ms 36980 KB Output is correct
2 Correct 513 ms 36276 KB Output is correct
3 Correct 542 ms 35756 KB Output is correct
4 Correct 824 ms 37456 KB Output is correct
5 Correct 751 ms 36528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 715 ms 42576 KB Output is correct
2 Correct 710 ms 44776 KB Output is correct
3 Correct 702 ms 44536 KB Output is correct
4 Execution timed out 1002 ms 46168 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 747 ms 45132 KB Output is correct
2 Correct 622 ms 44168 KB Output is correct
3 Correct 661 ms 43504 KB Output is correct
4 Correct 989 ms 46060 KB Output is correct
5 Correct 908 ms 44624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 825 ms 48428 KB Output is correct
2 Correct 829 ms 50736 KB Output is correct
3 Correct 842 ms 50516 KB Output is correct
4 Execution timed out 1093 ms 51796 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 842 ms 51028 KB Output is correct
2 Correct 714 ms 50040 KB Output is correct
3 Correct 750 ms 49452 KB Output is correct
4 Execution timed out 1066 ms 51796 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 950 ms 56252 KB Output is correct
2 Correct 963 ms 64672 KB Output is correct
3 Correct 949 ms 64080 KB Output is correct
4 Execution timed out 1042 ms 67920 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 954 ms 59304 KB Output is correct
2 Correct 808 ms 57964 KB Output is correct
3 Correct 862 ms 62040 KB Output is correct
4 Execution timed out 1044 ms 67620 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 67724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 71368 KB Time limit exceeded
2 Halted 0 ms 0 KB -