Submission #388971

# Submission time Handle Problem Language Result Execution time Memory
388971 2021-04-13T12:01:56 Z tostes Mobile (BOI12_mobile) C++17
100 / 100
679 ms 35396 KB
#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
using namespace std;
#define _ << ' ' <<
#define pb push_back
#define all(x) begin(x), end(x)
#define mp make_pair
#define f first
#define s second
#define sz(x) int((x).size())
using ll = long long;
using db = long double;
using pl = pair<ll,ll>;
using pi = pair<int,int>;

vector < pair<double,double> > pt;
int n; 
double l;

bool pos(double k){
	double sm=0;
	for(int i=0; i<n; i++){
		if(abs(pt[i].s)>=k) continue;
		double sq = sqrt(k*k-pt[i].s*pt[i].s);
		if(pt[i].f-sq<=sm) sm=max(sm,pt[i].f+sq);
	}
	return sm>=l;
}

int main(){
//	ios::sync_with_stdio(false);
 //	cin.tie(0);
	//freopen("loan.in", "r", stdin);
	//freopen("loan.out", "w", stdout);
	scanf("%d %lf", &n, &l);
	pt.resize(n);
	for(auto &x: pt) scanf("%lf %lf", &x.f, &x.s);
	double lo=0, hi=1e10;

	while((hi-lo)>0.00001){
		double mid=(lo+hi)/2;
		if(pos(mid)) hi=mid;
		else lo=mid;
	}
	printf("%.6lf\n", lo);
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |  scanf("%d %lf", &n, &l);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:38:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |  for(auto &x: pt) scanf("%lf %lf", &x.f, &x.s);
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 4 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1356 KB Output is correct
2 Correct 52 ms 2564 KB Output is correct
3 Correct 34 ms 1644 KB Output is correct
4 Correct 43 ms 2636 KB Output is correct
5 Correct 26 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1512 KB Output is correct
2 Correct 41 ms 2104 KB Output is correct
3 Correct 44 ms 2488 KB Output is correct
4 Correct 45 ms 2688 KB Output is correct
5 Correct 49 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 1612 KB Output is correct
2 Correct 54 ms 1484 KB Output is correct
3 Correct 51 ms 1612 KB Output is correct
4 Correct 55 ms 1740 KB Output is correct
5 Correct 48 ms 2568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 1868 KB Output is correct
2 Correct 67 ms 1740 KB Output is correct
3 Correct 59 ms 1740 KB Output is correct
4 Correct 56 ms 1844 KB Output is correct
5 Correct 55 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 1868 KB Output is correct
2 Correct 65 ms 1868 KB Output is correct
3 Correct 59 ms 1868 KB Output is correct
4 Correct 57 ms 1848 KB Output is correct
5 Correct 54 ms 3012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 307 ms 8128 KB Output is correct
2 Correct 329 ms 8108 KB Output is correct
3 Correct 335 ms 8124 KB Output is correct
4 Correct 277 ms 8116 KB Output is correct
5 Correct 279 ms 15064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 343 ms 8012 KB Output is correct
2 Correct 362 ms 8116 KB Output is correct
3 Correct 302 ms 13872 KB Output is correct
4 Correct 279 ms 17456 KB Output is correct
5 Correct 279 ms 15300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 9676 KB Output is correct
2 Correct 404 ms 9680 KB Output is correct
3 Correct 396 ms 9796 KB Output is correct
4 Correct 336 ms 9676 KB Output is correct
5 Correct 331 ms 17584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 410 ms 9792 KB Output is correct
2 Correct 420 ms 9676 KB Output is correct
3 Correct 363 ms 16452 KB Output is correct
4 Correct 347 ms 21324 KB Output is correct
5 Correct 331 ms 18380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 419 ms 11212 KB Output is correct
2 Correct 469 ms 11252 KB Output is correct
3 Correct 462 ms 11332 KB Output is correct
4 Correct 399 ms 11212 KB Output is correct
5 Correct 384 ms 20396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 466 ms 11244 KB Output is correct
2 Correct 474 ms 11212 KB Output is correct
3 Correct 428 ms 19568 KB Output is correct
4 Correct 406 ms 24760 KB Output is correct
5 Correct 381 ms 21352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 479 ms 12812 KB Output is correct
2 Correct 542 ms 12748 KB Output is correct
3 Correct 555 ms 12816 KB Output is correct
4 Correct 452 ms 12748 KB Output is correct
5 Correct 451 ms 23876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 536 ms 12748 KB Output is correct
2 Correct 534 ms 12868 KB Output is correct
3 Correct 497 ms 22340 KB Output is correct
4 Correct 453 ms 28228 KB Output is correct
5 Correct 482 ms 24332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 643 ms 16128 KB Output is correct
2 Correct 679 ms 16140 KB Output is correct
3 Correct 650 ms 16148 KB Output is correct
4 Correct 557 ms 16068 KB Output is correct
5 Correct 559 ms 29652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 674 ms 15952 KB Output is correct
2 Correct 661 ms 16340 KB Output is correct
3 Correct 621 ms 28356 KB Output is correct
4 Correct 593 ms 35396 KB Output is correct
5 Correct 554 ms 30664 KB Output is correct