QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717081#8524. Weather ForecastyhdddWA 1ms7844kbC++141.6kb2024-11-06 16:49:432024-11-06 16:49:44

Judging History

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

  • [2024-11-06 16:49:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7844kb
  • [2024-11-06 16:49:43]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define mod 998244353ll
#define pii pair<int,int>
#define fi first
#define se second
#define mems(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define db double
using namespace std;
const int maxn=200010;
const int inf=1e18;
const db eps=1e-10;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

int n,k;
db a[maxn];
db lsh[maxn];int len;
#define lb(x) (x&(-x))
int tree[maxn];
void upd(int x,int w){
	while(x<=len)tree[x]=max(tree[x],w),x+=lb(x);
}
int que(int x){
	int res=0;
	while(x)res=max(res,tree[x]),x-=lb(x);
	return res;
}
bool check(db x){
	db sum=0;
	lsh[len=1]=0;
	for(int i=1;i<=n;i++)sum+=a[i]-x,lsh[++len]=sum;
	sort(lsh+1,lsh+len+1),len=unique(lsh+1,lsh+len+1)-lsh-1;
	for(int i=1;i<=len;i++)tree[i]=0;
	sum=0.0;
	for(int i=1;i<=n;i++){
		sum+=a[i]-x;
		if(sum>0){
			int p=lower_bound(lsh+1,lsh+len+1,sum)-lsh;
			int val=que(p-1)+1;upd(p,val);
		}
	}
	// cout<<x<<" "<<que(n)<<"\n";
	return que(n)>=k;
}
void work(){
	n=read();k=read();
	for(int i=1;i<=n;i++)a[i]=read();
	db l=1,r=1000.0;
	while(r-l>eps){
		db mid=(l+r)/2.0;
		if(!check(mid))r=mid;
		else l=mid;
	}
	printf("%.10lf\n",l);
}

// \
444

bool Med;
int T;
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
//	cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=1;
	while(T--)work();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7844kb

input:

7 3
1 3 1 2 2 2 1

output:

1.6666666666

result:

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

Test #2:

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

input:

1 1
1

output:

1.0000000000

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #3:

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

input:

2 1
2 1

output:

1.5000000000

result:

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

Test #4:

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

input:

3 2
2 4 4

output:

2.0000000000

result:

wrong answer 1st numbers differ - expected: '3.00000', found: '2.00000', error = '1.00000'