# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
649977 |
2022-10-11T19:17:31 Z |
ymm |
Balloons (CEOI11_bal) |
C++17 |
|
370 ms |
2140 KB |
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
typedef long double ld;
typedef pair<ld, ld> pdd;
pdd in()
{
ll x, y;
cin >> x >> y;
return {x, y};
}
const int N = 200'010;
const int S = 8192;
double a[N], b[N];
ld x[N], r[N];
ld x_off = 0;
pdd f[N];
int len = 0;
void insert(pdd f)
{
::f[len] = f;
a[len] = f.first;
b[len] = f.second;
++len;
}
__attribute__((optimize("Ofast,unroll-loops"),target("avx2,fma4")))
double get(double x)
{
#define MIN(x, y) ((x)>(y)?(y):(x))
double ans = 1e30;
Loop (i,0,len) {
double tmp = a[i]*x + b[i];
ans = MIN(ans, tmp);
}
return ans;
#undef MIN
}
ld eval(pdd f, ld x)
{
return f.first * x + f.second;
}
void trim(ld x)
{
sort(f, f+len);
reverse(f, f+len);
int j = 0;
Loop (i,0,len) {
while (j && eval(f[j-1], x) >= eval(f[i], x))
--j;
f[j++] = f[i];
}
len = j;
Loop (i,0,len) {
f[i].second = eval(f[i], x);
a[i] = f[i].first;
b[i] = f[i].second;
}
x_off += x;
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cout << fixed << setprecision(3);
int n;
cin >> n;
for (int s = 0; s < n; s += S) {
int f = min(s+S, n);
Loop (i,s,f) {
auto [x, r] = in();
x -= x_off;
if (i == s || x > 3e6) {
trim(x);
x = 0;
}
r = sqrt(r);
r = min(r, (ld)get(x));
cout << r*r << '\n';
insert({0.5/r, -x*0.5/r});
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
340 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
792 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
1312 KB |
50000 numbers |
2 |
Correct |
88 ms |
1052 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
1612 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
359 ms |
1860 KB |
115362 numbers |
2 |
Correct |
241 ms |
1448 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
337 ms |
1952 KB |
154271 numbers |
2 |
Correct |
370 ms |
2008 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
242 ms |
2140 KB |
200000 numbers |
2 |
Correct |
364 ms |
1964 KB |
199945 numbers |