QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#626975 | #8242. V-Diagram | wpoem | WA | 75ms | 4044kb | C++20 | 1.9kb | 2024-10-10 14:19:35 | 2024-10-10 14:19:35 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <stack>
using i64 = long long;
void solve()
{
#define tests
int n, cnt = 0, dt;
double ans = 0, sum = 0, pos = 1;
std::cin >> n;
std::vector <int> nums(n + 1);
for(int i = 1 ; i <= n ; i++){
std::cin >> nums[i];
if(nums[pos] > nums[i])
pos = i;
}
sum += nums[pos];
cnt++;
ans = sum / cnt;
int l = pos - 1, r = pos + 1;
while(l >= 1 || r <= n){
if(l >= 1 && r <= n){
dt = 0;
while(l - dt >= 1 && r + dt <= n && nums[l - dt] == nums[r + dt])
dt++;
if(l - dt >= 1 && r + dt <= n && nums[l - dt] > nums[r + dt]){
sum += nums[l];
l--;
cnt++;
}else{
sum += nums[r];
r++;
cnt++;
}
//ans = std::max(ans, sum / cnt);
}else{
if(l >= 1){
sum += nums[l];
l--;
cnt++;
}
if(r <= n){
sum += nums[r];
r++;
cnt++;
}
}
ans = std::max(ans, sum / cnt);
}
printf("%0.20lf\n",ans);
}
signed main()
{
std::cin.tie(nullptr)->sync_with_stdio(false);
int _{1};
#ifdef tests
std::cin >> _;
#endif
while(_--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3764kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.75000000000000000000 5.83333333333333303727
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 75ms
memory: 4044kb
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:
843938490.00000000000000000000 454252473.50000000000000000000 770302316.66666662693023681641 608562705.00000000000000000000 296293261.66666668653488159180 365718784.00000000000000000000 571816312.66666662693023681641 237830983.00000000000000000000 45613183.00000000000000000000 474479951.500000000000...
result:
wrong answer 1st numbers differ - expected: '833782882.6666666', found: '843938490.0000000', error = '0.0121802'