第八个点会wa?求大佬解释
查看原帖
第八个点会wa?求大佬解释
181715
gjh303987897楼主2021/9/18 17:12
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int a[10001],b[10001];
int n,ans;
//递推 
//a[i]=b[i-1]-a[i-1]-a[i-2];
int check(){
	for(register int i=2;i<=n;i++){
		a[i]=b[i-1]-a[i-1]-a[i-2];
		if(a[i]<0){
		 return 0;
		}
		}
	ans++;
	return 0;
}
int c[10001];
int check1(){
	for(register int i=2;i<=n;i++){
		c[i]=b[i-1]-c[i-1]-c[i-2];
		if(c[i]<0){
		 return 0;
		}
		}
	ans++;
	return 0;
}  

int main()
{
	cin>>n;//b用作输入雷数量(右)   a用作放雷(左) 
	for(int i=1;i<=n;i++) cin>>b[i]; if(n==1) {
		cout<<1;return 0;
	}
	a[1]=1;
	check();
	a[1]=0;
	check1();
	cout<<ans;
	return 0;
}
2021/9/18 17:12
加载中...