# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
914663 |
2024-01-22T13:42:16 Z |
NoLove |
Balloons (CEOI11_bal) |
C++14 |
|
162 ms |
9828 KB |
/**
* author : Lăng Trọng Đạt
* created: 22-01-2024
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
int x[MAXN];
const double EPS = 1e-7;
double r[MAXN]; // r[i]: final radius of balloon i
int n;
double mx_radius(int i, int j) {
if (i == 0) return INF;
return (double)(x[i] - x[j])*(x[i] - x[j]) / 4. / r[i];
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("hi.inp", "r")) {
freopen("hi.inp", "r", stdin);
// freopen("hi.out", "w", stdout);
}
vi s = {0};
r[0] = INF;
x[0] = -1e8;
cin >> n;
int cnt = 0;
FOR(i, 1, n) {
cin >> x[i] >> r[i];
// do {
// if (r[i] >= r[s.back()])
// s.pop_back();
// r[i] = min(r[i], mx_radius(s.back(), i));
// } while (r[i] >= r)
while (r[i] - mx_radius(s.back(), i) > EPS or r[i] - r[s.back()] > EPS) {
db(s, r[i], r[s.back()])
r[i] = min(r[i], mx_radius(s.back(), i));
if (r[i] - r[s.back()] > EPS)
s.pop_back();
else break;
// db(i, s, r[i], r[s.back()])
// db(i, mx_radius(s.back(), i) < r[i], r[i] - mx_radius(s.back(), i) < EPS)
}
s.push_back(i);
cout << fixed << setprecision(4) << r[i] << "\n";
}
db(cnt)
}
Compilation message
bal.cpp: In function 'int32_t main()':
bal.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
| ^
bal.cpp:48:5: note: in expansion of macro 'FOR'
48 | FOR(i, 1, n) {
| ^~~
bal.cpp:47:9: warning: unused variable 'cnt' [-Wunused-variable]
47 | int cnt = 0;
| ^~~
bal.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | freopen("hi.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2548 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2908 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
3920 KB |
50000 numbers |
2 |
Correct |
48 ms |
4332 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
82 ms |
4936 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
5328 KB |
115362 numbers |
2 |
Correct |
85 ms |
6632 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
121 ms |
6228 KB |
154271 numbers |
2 |
Correct |
162 ms |
9676 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
6992 KB |
200000 numbers |
2 |
Correct |
139 ms |
9828 KB |
199945 numbers |