QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#856623#9966. High JumpIllusionaryDominance#WA 1ms4096kbC++201.7kb2025-01-14 14:51:122025-01-14 14:51:13

Judging History

你现在查看的是最新测评结果

  • [2025-01-14 14:51:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4096kb
  • [2025-01-14 14:51:12]
  • 提交

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] = max(p[i] * ((1 - p[trans]) * i + dp[trans]), p[i] * i);
    }

    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: 4096kb

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: 0ms
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: 0ms
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: 0ms
memory: 4096kb

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: 0
Accepted
time: 0ms
memory: 4096kb

input:

5
0.895888800 0.546833708 0.412641158 0.222811308 0.111288348

output:

1.7267857117

result:

ok found '1.7267857', expected '1.7267857', error '0.0000000'

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 4096kb

input:

6
0.980827003 0.951772494 0.903718587 0.460647740 0.409951573 0.403255978

output:

3.8044455289

result:

wrong answer 1st numbers differ - expected: '3.8259383', found: '3.8044455', error = '0.0056177'