QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#328695 | #8242. V-Diagram | yan_silva# | WA | 99ms | 3920kb | C++20 | 2.1kb | 2024-02-16 00:51:36 | 2024-02-16 00:51:37 |
Judging History
answer
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <random>
#include <cassert>
// #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
const int maxn = 3*100000 + 10;
// const int inf = 1000000000;
// const ll inf = 1000000000000000000LL;
// const ll mod = 998244353;
// const ll mod = 1000000007; // 10^9 + 7
int n;
int v[maxn];
double tryPrefix(int idMin)
{
double s = 0;
for(int i = 1 ; i < idMin ; i++)
s += v[i];
double ans = 0;
for(int i = idMin ; i <= n ; i++)
s += v[i], ans = max( ans , s/i );
return ans;
}
void solve(int testcase)
{
cin >> n;
for(int i = 1 ; i <= n ; i++)
cin >> v[i];
int idMin = 1;
for(int i = 2 ; i <= n ; i++)
if( v[i] < v[idMin] ) idMin = i;
double ans = tryPrefix( idMin );
reverse( v + 1 , v + n + 1 );
idMin = n - idMin + 1;
ans = max( ans , tryPrefix(idMin) );
cout << fixed << setprecision(15) << ans << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
for(int testcase = 1 ; testcase <= t ; testcase++)
solve( testcase );
}
Details
Tip: Click on the bar to expand more detailed information
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.750000000000000 5.833333333333333
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 99ms
memory: 3920kb
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.000000000000000 454252473.500000000000000 770302316.666666626930237 608562705.000000000000000 296293261.666666686534882 365718784.000000000000000 571816312.666666626930237 237830983.000000000000000 45613183.000000000000000 474479951.500000000000000 742247812.000000000000000 779975824.33333...
result:
wrong answer 1st numbers differ - expected: '833782882.6666666', found: '843938490.0000000', error = '0.0121802'