Submission #990998

# Submission time Handle Problem Language Result Execution time Memory
990998 2024-06-01T03:42:53 Z chanhchuong123 Mobile (BOI12_mobile) C++14
100 / 100
424 ms 27584 KB
#include<bits/stdc++.h>
using namespace std;

const bool multiTest = false;
#define task ""
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)

template<typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) a = b; else return 0; return 1;
}

const int MAX = 1000100;
int n, l;
int x[MAX];
int y[MAX];

bool ok(double dist) {
    double cur = 0;
    for (int i = 1; i <= n; ++i) {
        double l = x[i] - sqrt(dist * dist - 1LL * y[i] * y[i]), r = x[i] + sqrt(dist * dist - 1LL * y[i] * y[i]);
        if (l <= cur) maxi(cur, r);
    }
    return cur < l;
}

void process(void) {
    cin >> n >> l;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
    }
    double l = 1, r = 1.5e9;
    while (r - l > 1e-3) {
        double mid = (l + r) / 2;
        if (ok(mid)) l = mid;
        else r = mid;
    }
    cout << setprecision(4) << fixed << l;
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r",  stdin);
		freopen(task".out", "w", stdout);
	}

	int nTest = 1; if (multiTest) cin >> nTest;
	while (nTest--) {
		process();
	}

	return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:51:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:52:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2528 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 3 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 2 ms 2392 KB Output is correct
4 Correct 3 ms 2396 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 4700 KB Output is correct
2 Correct 19 ms 5752 KB Output is correct
3 Correct 14 ms 5212 KB Output is correct
4 Correct 29 ms 5796 KB Output is correct
5 Correct 14 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4700 KB Output is correct
2 Correct 25 ms 5468 KB Output is correct
3 Correct 29 ms 5724 KB Output is correct
4 Correct 30 ms 5704 KB Output is correct
5 Correct 34 ms 5980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 4696 KB Output is correct
2 Correct 19 ms 4700 KB Output is correct
3 Correct 21 ms 4700 KB Output is correct
4 Correct 41 ms 6780 KB Output is correct
5 Correct 31 ms 5464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 6748 KB Output is correct
2 Correct 22 ms 6748 KB Output is correct
3 Correct 25 ms 6744 KB Output is correct
4 Correct 43 ms 6748 KB Output is correct
5 Correct 35 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 6744 KB Output is correct
2 Correct 23 ms 6748 KB Output is correct
3 Correct 25 ms 7768 KB Output is correct
4 Correct 43 ms 8544 KB Output is correct
5 Correct 35 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 6748 KB Output is correct
2 Correct 114 ms 6748 KB Output is correct
3 Correct 112 ms 6748 KB Output is correct
4 Correct 196 ms 6748 KB Output is correct
5 Correct 175 ms 13392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 6744 KB Output is correct
2 Correct 206 ms 6796 KB Output is correct
3 Correct 124 ms 12384 KB Output is correct
4 Correct 208 ms 15952 KB Output is correct
5 Correct 239 ms 14056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 120 ms 6748 KB Output is correct
2 Correct 138 ms 6744 KB Output is correct
3 Correct 139 ms 6776 KB Output is correct
4 Correct 257 ms 6748 KB Output is correct
5 Correct 208 ms 14696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 6748 KB Output is correct
2 Correct 242 ms 6744 KB Output is correct
3 Correct 145 ms 13560 KB Output is correct
4 Correct 271 ms 18256 KB Output is correct
5 Correct 214 ms 15444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 6992 KB Output is correct
2 Correct 158 ms 6992 KB Output is correct
3 Correct 157 ms 6992 KB Output is correct
4 Correct 333 ms 6992 KB Output is correct
5 Correct 247 ms 15956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 7048 KB Output is correct
2 Correct 267 ms 7048 KB Output is correct
3 Correct 218 ms 15428 KB Output is correct
4 Correct 286 ms 20460 KB Output is correct
5 Correct 249 ms 17008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 171 ms 7252 KB Output is correct
2 Correct 205 ms 7248 KB Output is correct
3 Correct 184 ms 7296 KB Output is correct
4 Correct 329 ms 7288 KB Output is correct
5 Correct 295 ms 18516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 7252 KB Output is correct
2 Correct 313 ms 7308 KB Output is correct
3 Correct 200 ms 16976 KB Output is correct
4 Correct 342 ms 22768 KB Output is correct
5 Correct 286 ms 19052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 8020 KB Output is correct
2 Correct 255 ms 8016 KB Output is correct
3 Correct 224 ms 8072 KB Output is correct
4 Correct 411 ms 8272 KB Output is correct
5 Correct 358 ms 21732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 242 ms 8016 KB Output is correct
2 Correct 381 ms 15172 KB Output is correct
3 Correct 263 ms 20756 KB Output is correct
4 Correct 424 ms 27584 KB Output is correct
5 Correct 396 ms 23228 KB Output is correct