QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#706856 | #8242. V-Diagram | clear | WA | 73ms | 5988kb | C++17 | 1.9kb | 2024-11-03 13:43:12 | 2024-11-03 13:43:12 |
Judging History
answer
//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define int long long
#define ll __int128
#define double long double
#define lowbit(x) (x&(-x))
#define log(x) (31^__builtin_clz(x))
#define endl '\n'
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
typedef tuple<double,double,double>TDDD;
typedef tuple<int,int,int>TIII;
const int N = 2e5+10;
const int mod = 1e9+7 , P = 131;
const double PI = acos(-1);
const double eps = 1e-8;
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());//随机数
int read(){
char c=0;
int res=0;
int f=1;
while(!(c>='0'&&c<='9')){
if(c=='-'){
f=-f;
}
c=getchar();
}
while(c>='0'&&c<='9'){
res=(res<<3)+(res<<1)+c-'0';
c=getchar();
}
return res*f;
}
void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9) write(x/10);
putchar(char(x%10+'0'));
}
int n,w[N];
int pre[N];
void solve(){
cin>>n;
int minv=1e18,id=0;
for(int i=1;i<=n;i++){
cin>>w[i];
pre[i]=pre[i-1]+w[i];
if(w[i]<minv){
minv=w[i];
id=i;
}
}
double ans=0;
int l=id,r=id;
bool f1=false,f2=false;
while(1){
if(l>=1&&w[l-1]>w[l])l--;
else f1=true;
if(r<=n&&w[r]<w[r+1])r++;
else f2=true;
if(f1&&f2)break;
// cout<<l<<' '<<r<<endl;
ans=max(ans,(double)(pre[r]-pre[l-1])/(double)(r-l+1));
}
printf("%.20Lf\n",ans);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T;
cin>>T;
while(T--)solve();
#ifdef GREENQWQ
cerr<<fixed<<setprecision(10)<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5988kb
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: 0
Accepted
time: 73ms
memory: 3840kb
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:
833782882.66666666668606922030 435670789.66666666665696538985 770302316.66666666668606922030 608562705.00000000000000000000 296293261.66666666665696538985 319149416.33333333334303461015 571816312.66666666668606922030 223646002.33333333332848269492 39407315.66666666666787932627 383253737.666666666656...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 22ms
memory: 5940kb
input:
10000 4 194123849 79274911 191162487 570110764 86 957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...
output:
258668002.75000000000000000000 499947495.38372093022917397320 495489050.35294117647572420537 511519421.86301369863213039935 802995105.36363636364694684744 543693608.25000000000000000000 543366581.51612903224304318428 999544727.00000000000000000000 395528440.97435897434479556978 502458665.38461538462...
result:
wrong answer 2nd numbers differ - expected: '527118856.7555556', found: '499947495.3837209', error = '0.0515469'