自定义计分脚本不合理!
查看原帖
自定义计分脚本不合理!
782904
哈哈人生楼主2023/11/4 19:40

一下代码可以做到sub1超时,sub2AC,虽然只有40分,但测评状态是AC,望加强数据或订正自定义计分脚本。

#include<bits/stdc++.h>
using namespace std;
int n,x,maxx=-1;
bool mp[300005];
char ch;
bool check(int s){
	while(s<=maxx){
		if(mp[s])return 1;
		s+=x;
	}
	return 0;
}
int search(int l,int r){
	int mid,ans=-1;
	while(l<=r){
		mid=l+r>>1;
		if(check(mid))ans=mid,r=mid-1;
		else{
			int tmp=search(l,mid-1);
			if(tmp==-1)l=mid+1;
			else{
				ans=tmp;
				break;
			}
		}
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	while(n--){
		cin>>ch>>x;
		if(ch=='A')mp[x]=1,maxx=max(maxx,x);
		else cout<<search(0,x-1)<<endl;
	}
	return 0;
} 

AWA

2023/11/4 19:40
加载中...