QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#572796 | #8242. V-Diagram | ranxi | WA | 84ms | 3988kb | C++14 | 1.4kb | 2024-09-18 16:25:19 | 2024-09-18 16:25:20 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define alls(x) x.begin(),x.end()
#define ull unsigned long long
#define lowbit(x) x&-x
#define lc p<<1
#define rc p<<1|1
#define PII pair<int,int>
#define vi vector<int>
using namespace std;
const int mod = 998244353;
const int N = 2e5+10;
void solve()
{
int n;
cin >> n;
vi a(n);
for(auto &i:a)cin >> i;
long double sum = 0;
int x = 0;
for(int i = 0;i<n;i++)
{
if(a[i]<a[i-1] && a[i]<a[i+1]) {
x = i;
break;
}
}
long double ans = 0;
sum = a[x] + a[x+1] + a[x-1];
ans = sum/3;
// cout<<ans<<'\n';
int i = x-2,j = x+2;
// cout<<x<<'\n';
int cnt = 3;
while(i>=0 && j<n)
{
++cnt;
if(a[i]>a[j])
{
sum+=a[i];
i--;
ans = max(ans,sum/cnt);
}
else
{
sum+=a[j];
j++;
ans = max(ans,sum/cnt);
}
// cout<<ans<<'\n';
}
while(i>=0)
{
++cnt;
sum+=a[i];
i--;
ans = max(ans,sum/cnt);
}
while(j<n)
{
++cnt;
sum+=a[j];
j++;
ans = max(ans,sum/cnt);
}
cout<<ans<<'\n';
}
signed main()
{
cout<<fixed<<setprecision(20);
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int _ = 1;
cin >> _;
while(_--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3988kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.75000000000000000000 5.83333333333333333348
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 84ms
memory: 3844kb
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.66666666668606922030 435670789.66666666665696538985 -661353448.66666666668606922030 608562705.00000000000000000000 296293261.66666666665696538985 319149416.33333333334303461015 571816312.66666666668606922030 223646002.33333333332848269492 39407315.66666666666787932627 383253737.6666666666...
result:
wrong answer 1st numbers differ - expected: '833782882.6666666', found: '-597872882.6666666', error = '1.7170606'