Submission #952351

# Submission time Handle Problem Language Result Execution time Memory
952351 2024-03-23T15:32:00 Z coolsentenceidontremember Mobile (BOI12_mobile) C++17
100 / 100
510 ms 35284 KB
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second
#define db double

using namespace std;

void setIO(string s = ""){
 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 cout.tie(nullptr);
 if (s.size()){
	freopen((s+".in").c_str(), "r", stdin);
	freopen((s+".out").c_str(), "w", stdout);
	}
}
ll pow_mod(ll a, ll b, ll m){
	ll res = 1;
	a%=m;
	for (; b; b>>=1, a = (a*a)%m){
		if (b&1) res = (res*a)%m;
	}
	return res;
}

ll pow(ll a, ll b){
	ll res = 1;
	for (; b; b>>=1, a*=a){
		if (b&1) res *= a;
	}
	return res;
}



void GiveMeAnswer(){
   int n;
   db len;
   cin >> n >> len;
   pair<db, db> station[n];
   for (auto &a : station) cin >> a.ff >> a.ss;
   double l = 0, r = 1.5e9;
   while (r-l>1e-4){
   	   db m = (l+r)/2, mx = 0;
   	   for (int i = 0; i < n; i++){
   	   	db p = m*m-station[i].ss*station[i].ss;
   	   	if (p<0) continue;
   	   	p = sqrt(p);
   	   	db start = station[i].ff-p, end = station[i].ff+p;
   	   	if (start<mx) mx = max(mx, end);
		  }
		if (mx>=len) r = m;
		else l = m;
   }
   cout << fixed << setprecision(6) << l << '\n';
}


int main(){
   auto begin = chrono::high_resolution_clock::now();
   setIO();
   int tt = 1;
   //cin >> tt;
   for (int t = 1; t <= tt; t++) GiveMeAnswer();
   auto end = chrono::high_resolution_clock::now();
   // super cool C++ timer
   auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end-begin);
   auto fulltime = elapsed.count()*1e-9;
   cerr << "\n\nExecution time: " << fulltime << " seconds.\n";
   if (fulltime>1) cerr << "TLE!1!!1!!11!!1  C= C= C= C= C=+(;·w·)+";
   else cerr << "You safe brother";

   return 0;
}


Compilation message

mobile.cpp: In function 'void setIO(std::string)':
mobile.cpp:16:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  freopen((s+".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:17:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  freopen((s+".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 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 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 464 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2396 KB Output is correct
2 Correct 36 ms 2652 KB Output is correct
3 Correct 23 ms 1884 KB Output is correct
4 Correct 34 ms 2652 KB Output is correct
5 Correct 20 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2396 KB Output is correct
2 Correct 30 ms 2136 KB Output is correct
3 Correct 38 ms 2652 KB Output is correct
4 Correct 35 ms 2664 KB Output is correct
5 Correct 38 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2320 KB Output is correct
2 Correct 42 ms 2648 KB Output is correct
3 Correct 37 ms 2640 KB Output is correct
4 Correct 45 ms 3924 KB Output is correct
5 Correct 36 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3512 KB Output is correct
2 Correct 46 ms 3408 KB Output is correct
3 Correct 44 ms 3024 KB Output is correct
4 Correct 46 ms 3916 KB Output is correct
5 Correct 45 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 3508 KB Output is correct
2 Correct 47 ms 3408 KB Output is correct
3 Correct 44 ms 2904 KB Output is correct
4 Correct 47 ms 3924 KB Output is correct
5 Correct 43 ms 3152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 12712 KB Output is correct
2 Correct 261 ms 15956 KB Output is correct
3 Correct 246 ms 15476 KB Output is correct
4 Correct 223 ms 17748 KB Output is correct
5 Correct 216 ms 15024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 16464 KB Output is correct
2 Correct 274 ms 14672 KB Output is correct
3 Correct 212 ms 13904 KB Output is correct
4 Correct 228 ms 17580 KB Output is correct
5 Correct 237 ms 15444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 14992 KB Output is correct
2 Correct 287 ms 18888 KB Output is correct
3 Correct 281 ms 18512 KB Output is correct
4 Correct 272 ms 21464 KB Output is correct
5 Correct 283 ms 17596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 19676 KB Output is correct
2 Correct 332 ms 17744 KB Output is correct
3 Correct 261 ms 16460 KB Output is correct
4 Correct 275 ms 21332 KB Output is correct
5 Correct 259 ms 18664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 297 ms 17236 KB Output is correct
2 Correct 328 ms 22268 KB Output is correct
3 Correct 325 ms 21328 KB Output is correct
4 Correct 318 ms 24660 KB Output is correct
5 Correct 296 ms 20348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 342 ms 22864 KB Output is correct
2 Correct 368 ms 20584 KB Output is correct
3 Correct 306 ms 19692 KB Output is correct
4 Correct 312 ms 24812 KB Output is correct
5 Correct 304 ms 21484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 374 ms 19720 KB Output is correct
2 Correct 376 ms 25228 KB Output is correct
3 Correct 374 ms 24460 KB Output is correct
4 Correct 365 ms 28428 KB Output is correct
5 Correct 353 ms 24072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 26124 KB Output is correct
2 Correct 420 ms 23380 KB Output is correct
3 Correct 343 ms 22456 KB Output is correct
4 Correct 364 ms 28244 KB Output is correct
5 Correct 347 ms 24328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 425 ms 24656 KB Output is correct
2 Correct 489 ms 31432 KB Output is correct
3 Correct 461 ms 30544 KB Output is correct
4 Correct 462 ms 35028 KB Output is correct
5 Correct 443 ms 29512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 482 ms 32336 KB Output is correct
2 Correct 510 ms 29264 KB Output is correct
3 Correct 435 ms 28356 KB Output is correct
4 Correct 465 ms 35284 KB Output is correct
5 Correct 440 ms 30804 KB Output is correct