QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#856619 | #9966. High Jump | IllusionaryDominance# | WA | 1ms | 4096kb | C++20 | 1.6kb | 2025-01-14 14:48:34 | 2025-01-14 14:48:34 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
const int N = 6e5 + 10;
const double eps = 1e-9;
const ll MOD = 1e9 + 7;
struct Vector3 {
double x, y, z;
};
struct edge {
int from, to;
}eg[N << 1];
int front[N], num;
void add(int x, int y) {eg[++ num] = (edge){front[x], y}; front[x] = num;}
bool operator==(Vector3 V1, Vector3 V2) {return (abs(V1.x - V2.x) + abs(V1.y - V2.y) + (abs(V1.z - V2.z)) <= eps);}
double operator*(Vector3 V1, Vector3 V2) {return V1.x * V2.x + V1.y * V2.y + V1.z * V2.z;}
Vector3 operator+(Vector3 V1, Vector3 V2) {return (Vector3){V1.x + V2.x, V1.y + V2.y, V1.z + V2.z};}
Vector3 operator-(Vector3 V1, Vector3 V2) {return (Vector3){V1.x - V2.x, V1.y - V2.y, V1.z - V2.z};}
double dis(Vector3 V) {return sqrt(V.x * V.x + V.y * V.y + V.z * V.z);}
ll ksm(ll x, ll y) {
ll re = 1;
for (; y; y >>= 1) {
if(y & 1) re = re * x % MOD;
x = x * x % MOD;
}
return re;
}
void solve() {
int n;
cin >> n;
vector<double> p(n + 10), dp(n + 10);
for (int i = 1; i <= n; ++ i) cin >> p[i];
dp[n] = p[n] * n;
int trans = n;
for (int i = n - 1; i; -- i) {
while(trans - 1 > i && - p[trans - 1] * i + dp[trans - 1] > p[trans] * i + dp[trans]) -- trans;
dp[i] = p[i] * ((1 - p[trans]) * i + dp[trans]);
}
double ans = 0;
for (int i = 1; i <= n; ++ i) ans = max(ans, dp[i]);
cout << fixed << setprecision(10) << ans;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while(T --) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3968kb
input:
5 0.9 0.85 0.6 0.456000 0.000000017
output:
2.4752000066
result:
ok found '2.4752000', expected '2.4752000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4096kb
input:
1 0.000000001
output:
0.0000000010
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
2 0.828496829 0.645649353
output:
1.3634152706
result:
ok found '1.3634153', expected '1.3634153', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 4096kb
input:
3 0.551197930 0.393255768 0.207104323
output:
0.8679565056
result:
ok found '0.8679565', expected '0.8679565', error '0.0000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
4 0.795361966 0.464795612 0.331129862 0.063526593
output:
1.3388290401
result:
ok found '1.3388290', expected '1.3388290', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3968kb
input:
5 0.895888800 0.546833708 0.412641158 0.222811308 0.111288348
output:
1.5169459956
result:
wrong answer 1st numbers differ - expected: '1.7267857', found: '1.5169460', error = '0.1215204'