QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726232 | #8242. V-Diagram | ChiTang | WA | 108ms | 3896kb | C++17 | 1.2kb | 2024-11-08 22:28:48 | 2024-11-08 22:28:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
const int N = 2e5 + 10;
void solve()
{
int n;
cin >> n;
vector<int> a(n + 5);
int p = 0;
int sum = 0;
for(int i = 1; i <= n; i ++ )
{
cin >> a[i];
sum += a[i];
}
for(int i = 2; i <= n; i ++ )
{
if(a[i] > a[i - 1]) break;
p = i;
}
// cout << p << endl;
int l = 1, r = n;
double s1 = sum, a1 = 1.0 * sum / n;
for(int i = 1; i < p - 1; i ++ )
{
s1 -= a[i];
double tmp = 1.0 * s1 / (n - i);
if(tmp > a1)
{
a1 = max(a1, tmp);
}
}
double s2 = sum, a2 = 1.0 * sum / n;
for(int i = n; i > p + 1; i -- )
{
s2 -= a[i];
double tmp = 1.0 * s2 / (i - 1);
if(tmp > a2)
{
a2 = max(a2, tmp);
}
}
// cout << a1 << ' ' << a2 << endl;
double ans = max(a1, a2);
cout << fixed << setprecision(12) << ans << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while(t -- )
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3896kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.750000000000 5.833333333333
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 108ms
memory: 3804kb
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:
-597872882.666666626930 435670789.666666686535 -661353448.666666626930 608562705.000000000000 296293261.666666686535 319149416.333333313465 571816312.666666626930 223646002.333333343267 39407315.666666664183 383253737.666666686535 -697292126.666666626930 -651679941.000000000000 490276408.33333331346...
result:
wrong answer 1st numbers differ - expected: '833782882.6666666', found: '-597872882.6666666', error = '1.7170606'