QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#445663#8524. Weather Forecastucup-team1231#WA 1ms10104kbC++141.4kb2024-06-16 07:21:092024-06-16 07:21:09

Judging History

This is the latest submission verdict.

  • [2024-06-16 07:21:09]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 10104kb
  • [2024-06-16 07:21:09]
  • Submitted

answer

#pragma GCC optimize("unroll-loops","omit-frame-pointer","inline","rounding-math")//,"signaling-nans")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
// typedef float16_t fp16;
typedef float fp16;
typedef float fp32;
typedef double fp64;
typedef long double fp128;
typedef double ld;
#define SZ 666666
int n,k;
typedef double ld;
ld a[SZ],g[SZ];
int gx[SZ],gy[SZ];
int bb[SZ];
int qry(int x) {
    int s=-2e9;
    for(;x>=1;x-=x&-x) s=max(s,bb[x]);
    return s;
}
void edt(int x,int y) {
    for(;x<=n+5;x+=x&-x) bb[x]=max(bb[x],y);
}
int main() {
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) scanf("%lf",a+i);
    ld l=0,r=2000;
    while(r-l>1e-5) {
        // cout<<l<<"~"<<r<<"\n";
        ld m=(l+r)/2;
        for(int i=1;i<=n;++i) g[i]=g[i-1]+a[i]-m,g[i]=g[i];
        for(int i=0;i<=n;++i) gx[i]=i;
        sort(gx,gx+1+n,[&](int a,int b) {return g[a]<g[b];});
        for(int i=0;i<=n;++i) gy[gx[i]]=i;
        for(int i=0;i<=n+5;++i) bb[i]=-2e9;
        int ans=0;
        for(int i=0;i<=n;++i) {
            int f=qry(gy[i]+1)+1;
            if(g[i]>=0) f=max(f,1);
            ans=f;
            edt(gy[i]+1,f);
        }
        // cout<<ans<<" "<<k<<"+\n";
        // for(int i=0;i<=n;++i)
        //     cout<<g[i]<<",";
        // cout<<"\n";
        if(ans<k) r=m;
        else l=m;
    }
    printf("%.10lf\n",l);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 10104kb

input:

7 3
1 3 1 2 2 2 1

output:

1.6666650772

result:

ok found '1.66667', expected '1.66667', error '0.00000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 10044kb

input:

1 1
1

output:

0.9999945760

result:

ok found '0.99999', expected '1.00000', error '0.00001'

Test #3:

score: 0
Accepted
time: 1ms
memory: 10036kb

input:

2 1
2 1

output:

1.4999955893

result:

ok found '1.50000', expected '1.50000', error '0.00000'

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 10044kb

input:

3 2
2 4 4

output:

3.3333301544

result:

wrong answer 1st numbers differ - expected: '3.00000', found: '3.33333', error = '0.33333'