QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#677461 | #8242. V-Diagram | tsogsummit# | WA | 162ms | 3848kb | C++17 | 1.4kb | 2024-10-26 12:11:46 | 2024-10-26 12:11:47 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
ll n;
cin >> n;
ll nums[n];
double sum = 0;
for(int i = 0; i < n; i++) {
cin >> nums[i];
sum += nums[i];
}
double ans = sum / n;
int left = 0, right = n - 1;
while(n > 3 && (nums[left] < n || nums[right] < n)) {
double subAns = 0;
if(nums[left] < n) {
subAns = (sum - nums[left]) / (n - 1);
ans = max(ans, subAns);
}
if(nums[right] < n) {
subAns = (sum - nums[right]) / (n - 1);
ans = max(ans, subAns);
}
if(nums[right] < n && nums[left] < n && n >= 5) {
subAns = (sum - nums[right] - nums[left]) / (n - 2);
ans = max(ans, subAns);
sum -= (nums[right] + nums[left]);
right--;
left++;
} else {
if(nums[right] < n) {
sum -= nums[right];
n--;
right--;
} else {
sum -= nums[left];
left++;
n--;
}
}
}
ans = max(ans, sum / (right + 1));
cout << fixed;
cout << setprecision(18) << ans << endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.750000000000000000 5.833333333333333037
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 162ms
memory: 3660kb
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.666666626930236816 435670789.666666686534881592 770302316.666666626930236816 608562705.000000000000000000 296293261.666666686534881592 319149416.333333313465118408 571816312.666666626930236816 223646002.333333343267440796 39407315.666666664183139801 383253737.666666686534881592 734363638.6...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 82ms
memory: 3844kb
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:
258668002.750000000000000000 499947495.383720934391021729 495489050.352941155433654785 511519421.863013684749603271 472025965.699999988079071045 543693608.250000000000000000 543366581.516129016876220703 254833443.199999988079071045 395528440.974358975887298584 502458665.384615361690521240 564217787....
result:
wrong answer 2nd numbers differ - expected: '527118856.7555556', found: '499947495.3837209', error = '0.0515469'