Submission #47281611
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
using ld = long double;
const ld DELTA = 0.9, WORSE = numeric_limits<int>::min();
// stored DELTA ^ p
ld pow_d[5005];
// 1 + DELTA + .. DELTA ^ K
ld sum_k(int K) {
return 1 * (1 - pow_d[K]) / (1 - DELTA);
}
// 1200 / sqrt(K)
ld off_term(int K) {
if(K == 0)
return 0;
ld T = 1200;
T /= sqrtl(K);
return T;
}
void solve() {
int n;
cin >> n;
vector<int>a(n);
for(auto &i: a)
cin >> i;
vector<vector<ld>>dp(n + 1, vector<ld>(n + 1, WORSE));
dp[0][0] = 0;
for(int i = 1; i <= n; i++) {
ld can_pick = a[i - 1];
for(int picked = 1; picked <= n; picked++)
dp[i][picked] = dp[i - 1][picked];
for(int picked = 1; picked <= n; picked++) {
ld best = dp[i - 1][picked - 1];
if(best == WORSE)
continue;
/*
let prev ans be Q
if we want to add current performance to Q
Q = Q - 1200 / root(picked - 1)
Q = Q * (1 + DELTA + ... DELTA ^ (picked - 1))
Q = Q * DELTA
Q = Q + perf
Q = Q / (1 + DELTA + .... DELTA ^ (picked))
Q = Q - 1200 / root(picked)
*/
best += off_term(picked - 1);
best *= sum_k(picked - 1);
best *= DELTA;
best += can_pick;
best /= sum_k(picked);
best -= off_term(picked);
dp[i][picked] = max(dp[i][picked], best);
}
}
cout << setprecision(10) << *max_element(begin(dp[n]), end(dp[n])) << '\n';
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
pow_d[0] = 1;
for(int i = 1; i <= 5002; i++) {
pow_d[i] = (pow_d[i - 1] * DELTA);
}
int T = 1;
while(T--) solve();
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Maximize Rating |
| User | GojoSaturo |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1975 Byte |
| Status | WA |
| Exec Time | 380 ms |
| Memory | 394388 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 475 | ||||||
| Status |
|
|
| 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 | 3840 KiB |
| example_01.txt | AC | 1 ms | 3912 KiB |
| example_02.txt | AC | 1 ms | 3764 KiB |
| hand_00.txt | AC | 380 ms | 394284 KiB |
| hand_01.txt | AC | 1 ms | 3888 KiB |
| hand_02.txt | AC | 379 ms | 394388 KiB |
| hand_03.txt | AC | 379 ms | 394292 KiB |
| hand_04.txt | AC | 1 ms | 3780 KiB |
| hand_05.txt | AC | 1 ms | 3736 KiB |
| hand_06.txt | AC | 379 ms | 394296 KiB |
| random_00.txt | AC | 377 ms | 393020 KiB |
| random_01.txt | AC | 365 ms | 378960 KiB |
| random_02.txt | AC | 7 ms | 9328 KiB |
| random_03.txt | AC | 1 ms | 3904 KiB |
| random_04.txt | WA | 1 ms | 3876 KiB |
| random_05.txt | AC | 377 ms | 391764 KiB |
| random_06.txt | AC | 370 ms | 385040 KiB |
| random_07.txt | AC | 5 ms | 7860 KiB |
| random_08.txt | WA | 1 ms | 3916 KiB |
| random_09.txt | WA | 1 ms | 3808 KiB |
| random_10.txt | AC | 372 ms | 386412 KiB |
| random_11.txt | AC | 369 ms | 383584 KiB |
| random_12.txt | AC | 6 ms | 8428 KiB |
| random_13.txt | AC | 1 ms | 3784 KiB |
| random_14.txt | AC | 1 ms | 3880 KiB |
| random_15.txt | AC | 366 ms | 380512 KiB |
| random_16.txt | AC | 379 ms | 394016 KiB |
| random_17.txt | AC | 6 ms | 8952 KiB |
| random_18.txt | AC | 1 ms | 3896 KiB |
| random_19.txt | AC | 1 ms | 3780 KiB |
| random_20.txt | AC | 370 ms | 385100 KiB |
| random_21.txt | AC | 368 ms | 382400 KiB |
| random_22.txt | AC | 6 ms | 8268 KiB |
| random_23.txt | AC | 1 ms | 3904 KiB |
| random_24.txt | AC | 1 ms | 3892 KiB |