QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842120 | #9966. High Jump | ucup-team896# | RE | 9ms | 39176kb | C++20 | 1.5kb | 2025-01-04 10:22:15 | 2025-01-04 10:22:15 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }
using namespace std;
const int maxn = 500010;
struct line {
double k, b;
line() { k = 0, b = -1e9; }
line(double _k, double _b) { k = _k, b = _b; }
double F(int x) { return x * k + b; }
} t[maxn << 2];
int n;
double a[maxn], f[maxn];
#define mid ((l + r) >> 1)
void upd(int c, int l, int r, line v) {
if (t[c].k == 0 && t[c].b == -1e9) return t[c] = v, void();
if (t[c].F(mid) < v.F(mid)) swap(t[c], v);
if (v.k < t[c].k) upd(c << 1, l, mid, v);
else upd(c << 1 | 1, mid + 1, r, v);
}
double qry(int c, int l, int r, int x) {
if (l == r) return t[c].F(x);
if (x <= mid) return max(qry(c << 1, l, mid, x), t[c].F(x));
else return max(qry(c << 1 | 1, mid + 1, r, x), t[c].F(x));
}
#undef mid
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n;
rep (i, 1, n) cin >> a[i];
f[n] = n;
upd(1, 0, n, line(1 - a[n], a[n] * f[n]));
per (i, n - 1, 0) {
f[i] = i;
chkmx(f[i], qry(1, 0, n, i));
if (i != 0) upd(1, 0, n, line(1 - a[i], a[i] * f[i]));
}
cout << fixed << setprecision(20) << f[0] << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 4ms
memory: 37336kb
input:
5 0.9 0.85 0.6 0.456000 0.000000017
output:
2.47520000658920036329
result:
ok found '2.4752000', expected '2.4752000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 4ms
memory: 38568kb
input:
1 0.000000001
output:
0.00000000100000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 38280kb
input:
2 0.828496829 0.645649353
output:
1.36341527060640155256
result:
ok found '1.3634153', expected '1.3634153', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 37844kb
input:
3 0.551197930 0.393255768 0.207104323
output:
0.86795650559748505071
result:
ok found '0.8679565', expected '0.8679565', error '0.0000000'
Test #5:
score: 0
Accepted
time: 9ms
memory: 38540kb
input:
4 0.795361966 0.464795612 0.331129862 0.063526593
output:
1.33882904005673197823
result:
ok found '1.3388290', expected '1.3388290', error '0.0000000'
Test #6:
score: 0
Accepted
time: 4ms
memory: 38548kb
input:
5 0.895888800 0.546833708 0.412641158 0.222811308 0.111288348
output:
1.72678571170068373419
result:
ok found '1.7267857', expected '1.7267857', error '0.0000000'
Test #7:
score: 0
Accepted
time: 4ms
memory: 38020kb
input:
6 0.980827003 0.951772494 0.903718587 0.460647740 0.409951573 0.403255978
output:
3.82593831595728417483
result:
ok found '3.8259383', expected '3.8259383', error '0.0000000'
Test #8:
score: 0
Accepted
time: 8ms
memory: 38788kb
input:
7 0.964710946 0.660694845 0.569051685 0.519424206 0.347976236 0.103554534 0.003582098
output:
2.66048384589388620114
result:
ok found '2.6604838', expected '2.6604838', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 39176kb
input:
10 0.908256456 0.813576564 0.742549305 0.649326027 0.554646135 0.461422857 0.372638782 0.277958891 0.183440845 0.094656770
output:
3.46513326812143507283
result:
ok found '3.4651333', expected '3.4651333', error '0.0000000'
Test #10:
score: 0
Accepted
time: 4ms
memory: 37364kb
input:
14 0.965125864 0.957983158 0.894060589 0.767619278 0.708280001 0.562719570 0.524554410 0.428166908 0.332545137 0.257543419 0.171522463 0.080323478 0.048170500 0.020758694
output:
4.98681288351234908163
result:
ok found '4.9868129', expected '4.9868129', error '0.0000000'
Test #11:
score: 0
Accepted
time: 4ms
memory: 39040kb
input:
20 0.999312308 0.993123094 0.792022793 0.785833579 0.773356911 0.773356910 0.760880241 0.710678846 0.707633359 0.706159736 0.706159735 0.705865010 0.705177319 0.680125741 0.655074164 0.604872769 0.604185078 0.403084776 0.402397085 0.000098242
output:
11.72291089618293469243
result:
ok found '11.7229109', expected '11.7229109', error '0.0000000'
Test #12:
score: 0
Accepted
time: 4ms
memory: 39040kb
input:
35 0.999999999 0.500000000 0.333333333 0.250000000 0.200000000 0.166666667 0.142857143 0.125000000 0.111111111 0.100000000 0.090909091 0.083333333 0.076923077 0.071428571 0.066666667 0.062500000 0.058823529 0.055555556 0.052631579 0.050000000 0.047619048 0.045454545 0.043478261 0.041666667 0.0400000...
output:
1.97142858408387122715
result:
ok found '1.9714286', expected '1.9714286', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 37668kb
input:
42 0.999999997 0.999999957 0.999999558 0.999995984 0.999967570 0.999770574 0.998606056 0.992914780 0.970865633 0.906613334 0.772832688 0.578915971 0.379098588 0.222796093 0.121846038 0.063881487 0.032730211 0.016569178 0.008336477 0.004181321 0.002093945 0.001047795 0.000524103 0.000262103 0.0001310...
output:
11.07411163668109210789
result:
ok found '11.0741116', expected '11.0741116', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 37428kb
input:
50 0.991131730 0.919779550 0.909523499 0.902541075 0.893803502 0.838347025 0.830500600 0.816318610 0.806306448 0.805684783 0.804210835 0.798232009 0.789231219 0.781205446 0.770460902 0.721836276 0.721271617 0.714886066 0.706142418 0.691410488 0.679542322 0.679399638 0.638774737 0.631666488 0.5962186...
output:
18.74667571666845589107
result:
ok found '18.7466757', expected '18.7466757', error '0.0000000'
Test #15:
score: -100
Runtime Error
input:
75 0.720531716 0.718707013 0.709343553 0.694459021 0.689578156 0.682674306 0.679584797 0.678491929 0.670621566 0.666003031 0.665315768 0.659922689 0.659583167 0.658225062 0.658114386 0.653584609 0.649780198 0.639566830 0.636645846 0.630488992 0.628876218 0.628515225 0.615173462 0.613656515 0.6100964...