QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627098 | #8242. V-Diagram | zzfs# | WA | 0ms | 3940kb | C++14 | 917b | 2024-10-10 14:44:19 | 2024-10-10 14:44:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
int a[N];
int n;
void solve()
{
cin >> n;
a[0] = 0x3f3f3f3f;
int p = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
if (a[i] > a[i - 1])
{
p = i - 1;
break;
}
}
ll sum = 0;
double ans = 0;
sum = 0;
for (int i = 1; i <= n; i++)
{
sum += a[i];
if (i > p)
ans = max(ans, 1.0 * sum / i);
}
sum = 0;
for (int i = n; i >= 1; i--)
{
sum += a[i];
if (i < p)
ans = max(ans, 1.0 * sum / (n - i + 1));
}
cout << fixed << setprecision(15) << ans << endl;
}
int main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3940kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
5.666666666666667 7.500000000000000
result:
wrong answer 1st numbers differ - expected: '6.7500000', found: '5.6666667', error = '0.1604938'