QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#696873 | #8242. V-Diagram | Kopicy | WA | 0ms | 3944kb | C++23 | 1.5kb | 2024-11-01 04:37:59 | 2024-11-01 04:37:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for(int i=(a);i<=(b);++i)
#define sz(x) (int)x.size()
#define endl "\n"
const int N = 2e5, mod = 1e9 + 7, inf = 1e18;
void solve() {
int n;
cin>>n;
vector<int> a(n+5);
rep(i,1,n) cin>>a[i];
vector<int> pre(n+5);
rep(i,1,n) pre[i]=pre[i-1]+a[i];
vector<int> f(n+1),g(n+1);
#define db double
auto chk=[&](db x){
for(int i=1;i<=n;){
if(a[i+1]==a[i]){
i++;
continue;
}
int lo=i+1;
while(lo<=n && a[lo]<a[lo-1]) lo++;
int ro=lo;int lb=lo-1;
db mx=-inf;
while(ro<=n && a[ro]>a[ro-1]){
mx=max(1.0*pre[ro]-x*ro,mx);
ro++;
}
if(ro-i<3){
i=ro;
continue;
}
for(int j=i;j<lb;j++){
db ans2=pre[j-1]-(j-1)*x;
if(ans2<mx) return true;
}
i=ro;
}
return false;
};
db lo=0,ro=1e9;
while((ro-lo)>1e-6){
db mid=(lo+ro)/2;
if(chk(mid)) lo=mid;
else ro=mid;
}
cout<<setprecision(10)<<lo<<endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int64_t tt = 1;
cin >> tt;
rep(kase, 1, tt) solve();
}
/*
2
4
8 2 7 10
6
9 6 5 3 4 8
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3944kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.74999967 5.833332928
result:
wrong answer 1st numbers differ - expected: '6.7500000', found: '6.7499997', error = '0.0000000'