QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#442785#8524. Weather Forecastucup-team266#WA 7ms7100kbC++231.8kb2024-06-15 13:30:172024-06-15 13:30:17

Judging History

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

  • [2024-06-15 13:30:17]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:7100kb
  • [2024-06-15 13:30:17]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
const int INF=1e18;
struct BIT
{
	int t[200005];
int lowbit(int x)
{
	return x&(-x);	
} 
void update(int x,int d)
{ 
	for(int i=x;i<=200001;i+=lowbit(i)) t[i]=max(t[i],d);
}
int query(int x)
{
	int res=-inf;
	for(int i=x;i>=1;i-=lowbit(i)) res=max(res,t[i]);
	return res;
}
}bt;
int n,k,a[200005];
double s[200005],t[200005];
int rk[200005],dp[200005];

bool chk(double mid)
{
	for(int i=1;i<=n;i++) s[i]=(double)(a[i])-mid+s[i-1],t[i]=s[i];
	sort(t,t+1+n);
	memset(bt.t,-0x3f,sizeof(bt.t));
	memset(dp,-0x3f,sizeof(dp));
	
	for(int i=0;i<=n;i++) rk[i]=lower_bound(t+1,t+1+n,s[i])-t+1;
	dp[0]=0,bt.update(rk[0],0);
	for(int i=1;i<=n;i++) dp[i]=bt.query(rk[i])+1,bt.update(rk[i],dp[i]);
	return dp[n]>=k;
}
void solve()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	double L=0,R=1000.0;
	for(int iter=0;iter<50;iter++)
	{
		double mid=(L+R)*0.5;
		if(chk(mid)) L=mid;
		else R=mid;
	}
	cout<<fixed<<setprecision(12)<<L<<"\n";
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
//	cin>>_;
	while(_--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 7100kb

input:

7 3
1 3 1 2 2 2 1

output:

1.666666666666

result:

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

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 7004kb

input:

1 1
1

output:

500.000000000000

result:

wrong answer 1st numbers differ - expected: '1.00000', found: '500.00000', error = '499.00000'