Submission #47270328


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/modint>

namespace {
using ModInt [[maybe_unused]] = atcoder::modint998244353;
using Num [[maybe_unused]] = long long int;
using Vec [[maybe_unused]] = std::vector<Num>;
using Set [[maybe_unused]] = std::set<Num>;
using Mset [[maybe_unused]] = std::multiset<Num>;
using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

template<typename T>
using Q [[maybe_unused]] = std::queue<T>;

template<typename T>
using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

void solve(std::istream& is, std::ostream& os) {
    Num n {0};
    is >> n;

    std::vector<double> ps(n);
    for(auto&& x : ps) {
        is >> x;
    }

    double answer {-1000000000000};
    for(Num i{0}; i<n; ++i) {
        const double r = ps.at(i) - 1200.0;
        if (i == 0) {
            answer = r;
        } else {
            answer = std::max(answer, r);
        }
    }

    std::vector<double> dp(n+1, -1000000000000);
    for(Num i{0}; i<n; ++i) {
        auto next = dp;
        const double r1 = ps.at(i) - 1200.0;
        next.at(1) = std::max(next.at(1), r1);
        answer = std::max(answer, next.at(1));

        for(Num j{2}; j<=n; ++j) {
            if ((i + 1) < j) {
                break;
            }

            double j1 = j - 1;
            double from = dp.at(j1);
            from += 1200 / std::sqrt(static_cast<double>(j1));
            from *= (1.0 - std::pow(0.9, j1)) / 0.1;
            from *= 0.9;
            from += ps.at(i);

            const double div = (1.0 - std::pow(0.9, j)) / 0.1;
            const double r = from / div - 1200 / sqrt(static_cast<double>(j));
            next.at(j) = std::max(next.at(j), r);
            answer = std::max(answer, next.at(j));
        }

        std::swap(dp, next);
    }

    os << std::setprecision(20) << answer << "\n";
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}

Submission Info

Submission Time
Task E - Maximize Rating
User zettsut
Language C++ 20 (gcc 12.2)
Score 475
Code Size 2001 Byte
Status AC
Exec Time 437 ms
Memory 4104 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3868 KiB
example_01.txt AC 1 ms 3852 KiB
example_02.txt AC 1 ms 3684 KiB
hand_00.txt AC 437 ms 4104 KiB
hand_01.txt AC 1 ms 3724 KiB
hand_02.txt AC 437 ms 4028 KiB
hand_03.txt AC 436 ms 3972 KiB
hand_04.txt AC 1 ms 3680 KiB
hand_05.txt AC 1 ms 3824 KiB
hand_06.txt AC 436 ms 4096 KiB
random_00.txt AC 435 ms 4048 KiB
random_01.txt AC 419 ms 3980 KiB
random_02.txt AC 8 ms 3836 KiB
random_03.txt AC 1 ms 3868 KiB
random_04.txt AC 1 ms 3852 KiB
random_05.txt AC 435 ms 3996 KiB
random_06.txt AC 426 ms 4056 KiB
random_07.txt AC 6 ms 3936 KiB
random_08.txt AC 1 ms 3972 KiB
random_09.txt AC 1 ms 3936 KiB
random_10.txt AC 427 ms 4088 KiB
random_11.txt AC 424 ms 3968 KiB
random_12.txt AC 7 ms 3952 KiB
random_13.txt AC 1 ms 3968 KiB
random_14.txt AC 1 ms 3940 KiB
random_15.txt AC 422 ms 4092 KiB
random_16.txt AC 436 ms 4072 KiB
random_17.txt AC 7 ms 3948 KiB
random_18.txt AC 1 ms 3924 KiB
random_19.txt AC 1 ms 3960 KiB
random_20.txt AC 426 ms 4052 KiB
random_21.txt AC 428 ms 4100 KiB
random_22.txt AC 7 ms 3984 KiB
random_23.txt AC 1 ms 3940 KiB
random_24.txt AC 1 ms 3976 KiB