QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#324274 | #8242. V-Diagram | ucup-team484# | WA | 758ms | 4092kb | C++17 | 1.3kb | 2024-02-10 17:31:48 | 2024-02-10 17:33:19 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
void solve() {
int n; cin >> n;
vector<int> a(n), b(n), c(n);
for (int i = 0; i < n; i++)
cin >> a[i];
ll sm = 0;
ld lo = 1, hi = 1e9;
for (int i = 0, j = -1, f = 0; i < n; i++) {
sm += a[i];
if (i > 0) {
b[i] = max(b[i - 1], i);
c[i] = max(c[i - 1], i);
}
while (b[i] + 1 < n && a[b[i]] >= a[b[i] + 1])
b[i]++;
while (c[i] + 1 < n && a[c[i]] <= a[c[i] + 1])
c[i]++;
if (i > c[0] && i > b[c[0] + 1])
lo = max(lo, sm / ld(i + 1));
}
for (int it = 0; it < 100; it++) {
ld mi = (lo + hi) / 2, pref = 0;
int ok = 0;
vector<pair<ld,int>> arr;
for (int i = 0; !ok && i < n; i++) {
pref += a[i] - mi;
int j = lower_bound(arr.begin(), arr.end(), make_pair(pref, n), greater<pair<ld,int>>()) - arr.begin();
if (j < size(arr) && i > c[arr[j].second] && i > b[c[arr[j].second]])
ok = 1;
if (arr.empty() || pref < arr.back().first)
arr.push_back(make_pair(pref, i));
}
if (ok == 1)
lo = mi;
else
hi = mi;
}
cout << fixed << setprecision(10) << lo << "\n";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int t; cin >> t; while (t--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4048kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.7500000000 5.8333333333
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 758ms
memory: 3788kb
input:
100000 3 948511478 739365502 813471668 3 881046825 27458122 398507422 3 987554257 399092415 924260278 3 984128569 125199021 716360525 3 529589236 45783262 313507287 3 645443456 85994112 226010681 3 914820717 228360911 572267310 3 418958362 56703604 195276041 3 64461646 26764720 26995581 3 914535039 ...
output:
833782882.6666666667 435670789.6666666667 770302316.6666666667 608562705.0000000000 296293261.6666666667 319149416.3333333333 571816312.6666666667 223646002.3333333333 39407315.6666666667 383253737.6666666667 734363638.6666666667 779975824.3333333333 490276408.3333333333 574448414.0000000000 3379802...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 384ms
memory: 4092kb
input:
10000 4 194123849 79274911 191162487 570110764 86 957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...
output:
280182720.6666666667 538557639.9545454545 495489050.3529411765 537734928.6410256411 472025965.7000000000 546154003.1250000000 543366581.5161290322 254833443.2000000000 447343683.3157894736 502458665.3846153846 564217787.3333333333 479468115.1182795699 469762036.6500000000 598722986.9285714285 537648...
result:
wrong answer 1st numbers differ - expected: '258668002.7500000', found: '280182720.6666667', error = '0.0831750'