关于小粉兔的挂科与压力
  • 板块灌水区
  • 楼主lishitang
  • 当前回复10
  • 已保存回复10
  • 发布时间2023/8/11 21:26
  • 上次更新2023/11/3 04:23:02
查看原帖
关于小粉兔的挂科与压力
736900
lishitang楼主2023/8/11 21:26
#include<iostream>
#include<cmath>
#define ll long long  
using namespace std;
int n,c;
ll st1[1000010][22];
int main(){
	cin>>n>>c;
	for(int i=1;i<=n;i++)cin>>st1[i][0];
	for(int j=1;j<=21;j++){
		for(int i=1;i+(1<<j)-1<=n;i++){
			st1[i][j]=max(st1[i][j-1],st1[i+(1<<(j-1))][j-1]);
		}
	}
	ll ans=1e18,ansk;
	for(int k=0;k<=n;k++){
		int p=log2(k);
		ll t=max(st1[1][p],st1[k-(1<<p)+1][p])+c*(n-k);
		if(k==0)t-=max(st1[1][p],st1[k-(1<<p)+1][p]);
//		cout<<max(st1[1][p],st1[k-1-(1<<p)+1][p])<<endl;
		if(ans>t)ans=t,ansk=k;
	}
	cout<<ansk<<" "<<ans<<endl;
	return 0;
} 

最后一个点wa,求调教

2023/8/11 21:26
加载中...