ABC E 求调
  • 板块学术版
  • 楼主hxyx_2
  • 当前回复2
  • 已保存回复3
  • 发布时间2025/1/11 21:48
  • 上次更新2025/1/12 11:23:21
查看原帖
ABC E 求调
1236897
hxyx_2楼主2025/1/11 21:48

WA。

#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define itn int
#define ull unsigned long long
ull T=1;
ull n,A[int(5*1e5+10)];
ull g[int(5*1e5+10)];
bool bj[int(5*1e5+10)];
ull last;
int main(){
//	cin>>T;
	while(T--){
		cin>>n;
		for(LL i=1;i<=n;i++)cin>>A[i];
		LL a=1;
		last=1e9+1;
//		for(LL a=1;a<=n;a++){
//			for(LL b=a+1;b<=n;b++){
//				if(A[a]*2<=A[b])ans++;
//			} 
//		}
		for(LL b=1;b<=n;b++){
			for(;a<=b;){
				if(A[a]*2>A[b]){
					g[b]=a-1;
					break;
				}
				else a++;
			}
		}
		LL ans=0;
		for(LL i=n;i>=1;i--){
			if(bj[i])continue;
			last=min(last,g[i]);
			while(bj[last])last--;
			if(last==0)break;
			ans++;
			bj[last]=1;
		}
		cout<<ans;
	}
	return 0;
}


2025/1/11 21:48
加载中...