Submission #368368

# Submission time Handle Problem Language Result Execution time Memory
368368 2021-02-20T01:35:29 Z ignaciocanta Mobile (BOI12_mobile) C++14
100 / 100
844 ms 51124 KB
#include <bits/stdc++.h>
 
using namespace std;
 
using tint = long long;
using ld = long double;
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
using pi = pair<tint,int>;
using pl = pair<tint,tint>;
using vi = vector<int>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vl = vector<tint>;
using vb = vector<bool>;
 
#define pb push_back
#define pf push_front
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sz(x) (int)(x).size()
#define ins insert
 
#define f first
#define s second
#define mp make_pair
 
#define DBG(x) cerr << #x << " = " << x << endl;
 
const int MOD = 1e9+7;
const tint mod = 998244353;
const int MX = 515;
const tint INF = 1e18; 
const int inf = 2e9;
const ld PI = acos(ld(-1)); 
const ld eps = 1e-5;
 
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
 
template<class T> void remDup(vector<T> &v){ 
    sort(all(v)); v.erase(unique(all(v)),end(v));
}
 
template<class T> bool ckmin(T& a, const T& b) {
    return b < a ? a = b, 1 : 0; 
} 
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; 
}
 
bool valid(int x, int y, int n, int m){
    return (0<=x && x<n && 0<=y && y<m);
}
 
int cdiv(int a, int b) { return a/b+((a^b)>0&&a%b); } //redondea p arriba
int fdiv(int a, int b) { return a/b-((a^b)<0&&a%b); } //redondea p abajo
 
void NACHO(string name = ""){
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
		freopen((name+".in").c_str(), "r", stdin);
		freopen((name+".out").c_str(), "w", stdout);
	}
}
 
int main(){
	NACHO();
	int n; tint l; cin >> n >> l;
	vpl a (n);
	F0R(i, n) cin >> a[i].f >> a[i].s;
	double low = 0, high = double(5e9);
	while(high-low > eps){
		double mid = low+(high-low)/2;
		vector<pair<double, double>> ran (n);
		F0R(i, n){
			// mid*mid = p.y*p.y+x*x
			double dist = sqrt(mid*mid-a[i].s*a[i].s);
			ran[i] = mp(a[i].f-dist, a[i].f+dist);
		}
		double ri = 0;
		F0R(i, n){
			if(ran[i].f <= ri) ri = max(ri, ran[i].s);
		}
		if(ri >= l) high = mid;
		else low = mid;
	}
	cout << fixed << setprecision(4) << high << "\n";
}

Compilation message

mobile.cpp: In function 'void NACHO(std::string)':
mobile.cpp:69:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   69 |   freopen((name+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:70:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   70 |   freopen((name+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 492 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 4 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 492 KB Output is correct
2 Correct 4 ms 592 KB Output is correct
3 Correct 4 ms 492 KB Output is correct
4 Correct 4 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
4 Correct 5 ms 876 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3564 KB Output is correct
2 Correct 44 ms 3820 KB Output is correct
3 Correct 29 ms 2668 KB Output is correct
4 Correct 62 ms 3920 KB Output is correct
5 Correct 29 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3564 KB Output is correct
2 Correct 46 ms 3356 KB Output is correct
3 Correct 54 ms 3956 KB Output is correct
4 Correct 54 ms 4076 KB Output is correct
5 Correct 62 ms 4588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3820 KB Output is correct
2 Correct 45 ms 4076 KB Output is correct
3 Correct 46 ms 3948 KB Output is correct
4 Correct 74 ms 5356 KB Output is correct
5 Correct 57 ms 4092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 5072 KB Output is correct
2 Correct 56 ms 4944 KB Output is correct
3 Correct 58 ms 4588 KB Output is correct
4 Correct 75 ms 5484 KB Output is correct
5 Correct 65 ms 4844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 4972 KB Output is correct
2 Correct 55 ms 4944 KB Output is correct
3 Correct 65 ms 4560 KB Output is correct
4 Correct 83 ms 5456 KB Output is correct
5 Correct 65 ms 4716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 272 ms 20596 KB Output is correct
2 Correct 301 ms 23788 KB Output is correct
3 Correct 312 ms 23424 KB Output is correct
4 Correct 382 ms 25580 KB Output is correct
5 Correct 375 ms 23020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 307 ms 24300 KB Output is correct
2 Correct 467 ms 22764 KB Output is correct
3 Correct 333 ms 21740 KB Output is correct
4 Correct 415 ms 25324 KB Output is correct
5 Correct 369 ms 23404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 334 ms 24428 KB Output is correct
2 Correct 379 ms 28492 KB Output is correct
3 Correct 368 ms 27884 KB Output is correct
4 Correct 476 ms 31180 KB Output is correct
5 Correct 434 ms 27244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 380 ms 29036 KB Output is correct
2 Correct 532 ms 27264 KB Output is correct
3 Correct 382 ms 25964 KB Output is correct
4 Correct 467 ms 30924 KB Output is correct
5 Correct 440 ms 27884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 414 ms 28396 KB Output is correct
2 Correct 438 ms 33132 KB Output is correct
3 Correct 429 ms 32508 KB Output is correct
4 Correct 547 ms 35888 KB Output is correct
5 Correct 503 ms 31340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 442 ms 33840 KB Output is correct
2 Correct 587 ms 31536 KB Output is correct
3 Correct 431 ms 30700 KB Output is correct
4 Correct 539 ms 35692 KB Output is correct
5 Correct 515 ms 32472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 440 ms 32404 KB Output is correct
2 Correct 497 ms 37816 KB Output is correct
3 Correct 495 ms 37040 KB Output is correct
4 Correct 623 ms 41108 KB Output is correct
5 Correct 589 ms 36628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 538 ms 38892 KB Output is correct
2 Correct 689 ms 36120 KB Output is correct
3 Correct 495 ms 34964 KB Output is correct
4 Correct 626 ms 40980 KB Output is correct
5 Correct 582 ms 37012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 560 ms 40416 KB Output is correct
2 Correct 629 ms 47212 KB Output is correct
3 Correct 620 ms 46316 KB Output is correct
4 Correct 781 ms 51040 KB Output is correct
5 Correct 710 ms 45292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 652 ms 48364 KB Output is correct
2 Correct 844 ms 45024 KB Output is correct
3 Correct 637 ms 44160 KB Output is correct
4 Correct 793 ms 51124 KB Output is correct
5 Correct 732 ms 46444 KB Output is correct