QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#563259 | #8524. Weather Forecast | qwqwf# | WA | 2ms | 8792kb | C++14 | 1.4kb | 2024-09-14 08:50:22 | 2024-09-14 08:50:23 |
Judging History
answer
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
//#pragma GCC optimize("Ofast","unroll-loops","inline")
#include<bits/stdc++.h>
#define ll long long
//#define int ll
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int N=2e5+10,M=1e6+10,mod=998244353;
const double eps=1e-5;
int n,k,a[N],w[N],tot,f[N];
double b[N],c[N];
struct Bit{
int s[N];
inline void init(){memset(s,0,sizeof(s));}
inline int lb(int x){return x&(-x);}
void upd(int x,int v){for(;x<=n;x+=lb(x)) s[x]=max(s[x],v);}
int qry(int x){int res=0;for(;x;x-=lb(x)) res=max(res,s[x]);return res;}
}tr;
bool chk(double x){
tot=0;
tr.init();
for(int i=1;i<=n;i++) b[i]=a[i]-x;
for(int i=1;i<=n;i++) b[i]+=b[i-1],c[++tot]=b[i];
sort(c+1,c+tot+1);tot=unique(c+1,c+tot+1)-c-1;
for(int i=1;i<=n;i++){
if(b[i]>=0) w[i]=lower_bound(c+1,c+tot+1,b[i])-c;
else w[i]=-1;
}
for(int i=1;i<=n;i++) f[i]=0;
for(int i=1;i<=n;i++) if(w[i]!=-1) f[i]=tr.qry(w[i])+1,tr.upd(w[i],f[i]);
return f[n]>=k;
}
signed main(){
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
double l=1,r=3;
while(r-l>eps){
double mid=(l+r)/2;
if(chk(mid)) l=mid;
else r=mid;
}
printf("%.8lf\n",(l+r)/2);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 8772kb
input:
7 3 1 3 1 2 2 2 1
output:
1.66666794
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8204kb
input:
1 1 1
output:
1.00000381
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 8620kb
input:
2 1 2 1
output:
1.50000381
result:
ok found '1.50000', expected '1.50000', error '0.00000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 8792kb
input:
3 2 2 4 4
output:
2.99999619
result:
ok found '3.00000', expected '3.00000', error '0.00000'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 8428kb
input:
4 2 6 7 3 12
output:
2.99999619
result:
wrong answer 1st numbers differ - expected: '6.50000', found: '3.00000', error = '3.50000'