Submission #853585

# Submission time Handle Problem Language Result Execution time Memory
853585 2023-09-24T17:05:55 Z noobnessOVERLOADED Mobile (BOI12_mobile) C++14
12 / 100
255 ms 24660 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define forn(i,j) for(ll i = 0; i < j; i++)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define p push
#define f first
#define s second

#define MOD 1000000007

void siout(string name = "") { 

	ios_base::sync_with_stdio(0);
	cin.tie(0); 
	
	if (!name.empty()) {
		freopen((name + ".in").c_str(), "r", stdin);
		freopen((name + ".out").c_str(), "w", stdout);
	}
}

int main(){
    siout();
    ll n, l;
    cin >> n >> l;
    pii coord[n];

    forn(i,n){ cin >> coord[i].f >> coord[i].s;}

    double hi = 1e9;
    double lo = 1;
    double ans;

    while(hi - lo > 1e-3){ 
        double mid = (hi + lo)/2;
        double m = 0;

        forn(i,n){
            double v = sqrt((mid*mid) - (coord[i].s*coord[i].s));       
            double a = coord[i].f - v;        
            double b = coord[i].f + v;
            
            if(a <= m){ m = max(m, b);}
        }

        if(m >= l){ hi = mid;} 
        else{ lo = mid;}
    }

    cout << fixed << setprecision(4) << hi << endl;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:37:12: warning: unused variable 'ans' [-Wunused-variable]
   37 |     double ans;
      |            ^~~
mobile.cpp: In function 'void siout(std::string)':
mobile.cpp:22:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   freopen((name + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:23:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   freopen((name + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 344 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 Incorrect 2 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 2 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 2 ms 572 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1828 KB Output is correct
2 Incorrect 19 ms 2084 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1808 KB Output is correct
2 Correct 21 ms 1624 KB Output is correct
3 Incorrect 31 ms 1880 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1624 KB Output is correct
2 Incorrect 21 ms 2140 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2648 KB Output is correct
2 Incorrect 24 ms 2496 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 2648 KB Output is correct
2 Incorrect 24 ms 2624 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 8532 KB Output is correct
2 Incorrect 129 ms 11888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 123 ms 12368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 129 ms 10308 KB Output is correct
2 Incorrect 146 ms 14344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 14928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 12156 KB Output is correct
2 Incorrect 194 ms 16540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 173 ms 17456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 169 ms 13592 KB Output is correct
2 Incorrect 195 ms 19028 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 198 ms 19756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 233 ms 16964 KB Output is correct
2 Incorrect 251 ms 23736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 255 ms 24660 KB Output isn't correct
2 Halted 0 ms 0 KB -