QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650097#8242. V-Diagram111111qqqqqqWA 217ms6024kbC++231.3kb2024-10-18 12:51:502024-10-18 12:51:51

Judging History

你现在查看的是最新测评结果

  • [2024-10-18 12:51:51]
  • 评测
  • 测评结果:WA
  • 用时:217ms
  • 内存:6024kb
  • [2024-10-18 12:51:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cmin(a,b) a=min(a,b)
#define cmax(a,b) a=max(a,b)
#define modd(a,b) a=a%b
#define pb push_back
#define db double
#define lowbit(x) x&(-x)
#define cerr(x) cout<<#x<<"="<<x<<endl
#define fi first
#define se second
const ll mod=1e9+7;
#define N 300010
const db eps=1e-10;
int n,pos;
db a[N],pre[N];
ll ksm(ll a,ll b) {ll ans=1,bs=a;while(b) {if(b&1) ans=ans*bs%mod;bs=bs*bs%mod;b>>=1;}return ans;}
bool ck(db mid) {
    for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i]-mid;
    db mx=0,mxx=0;
    for(int i=1;i<pos;i++) cmax(mx,pre[pos-1]-pre[i-1]);
    for(int i=pos+1;i<=n;i++) cmax(mxx,pre[i]-pre[pos]);
    return mx+mxx+a[pos]-mid>=0;
}
void solve() {
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    pos=1;
    for(int i=2;i<n;i++) if(a[i]<a[i-1] && a[i]<a[i+1]) pos=i;
    db l=0,r=*max_element(a+1,a+n+1),mid;
    // cout<<log2(1e18)<<endl;
    int cnt=0;
    while(fabs(r-l)>eps) {
        if(++cnt==100) break;
        mid=(l+r)/2;
        if(ck(mid)) l=mid;
        else r=mid;
    }
    cout<<fixed<<setprecision(12)<<l<<endl;
}
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T;
    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: 6024kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.749999999956
5.833333333314

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 217ms
memory: 5972kb

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.000000000000
454252473.500000000000
770302316.666666626930
608562705.000000000000
296293261.666666626930
365718784.000000000000
571816312.666666626930
237830983.000000000000
45613183.000000000000
474479951.500000000000
742247812.000000000000
779975824.333333253860
503399231.500000000000
64...

result:

wrong answer 1st numbers differ - expected: '833782882.6666666', found: '843938490.0000000', error = '0.0121802'