80分不知道错哪,看到讨论后明白了
  • 板块P1317 低洼地
  • 楼主詹亦乐
  • 当前回复4
  • 已保存回复4
  • 发布时间2020/5/29 18:36
  • 上次更新2023/11/7 01:30:56
查看原帖
80分不知道错哪,看到讨论后明白了
135607
詹亦乐楼主2020/5/29 18:36

我竟然会错意了......

我本来以为低洼地里能坑坑洼洼的......

#include<iostream>
using namespace std;
short lst1[10000];
bool lst2[10000];
int main()
{
	short n,max=0,x,s=0;
	cin>>n;
	for(int i=0;i<=n-1;i++){
		cin>>x;
		if(x>=max) max=x;
		else{
			lst2[i]=1;
		}
		lst1[i]=x;
	}
	max=0;
	bool a=0;
	for(int i=n-1;i>=0;i--){
		if(lst1[i]>=max){
			max=lst1[i];
			a=0;
		}
		else{
			if(lst2[i]){
				if(!a) s+=1;
				a=1;
			}
			else a=0;
		}
	}
	cout<<s<<endl;
	return 0;
}

不过仍然80分

2020/5/29 18:36
加载中...