萌新刚打atcoder,ACG058B求调
  • 板块学术版
  • 楼主ZHUHK
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/9/9 23:15
  • 上次更新2023/10/27 12:10:18
查看原帖
萌新刚打atcoder,ACG058B求调
304458
ZHUHK楼主2022/9/9 23:15

ACG058B求调 题目

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=5e3+10;
int n,f[N],a[N];
int main(){
	freopen("data.in","r",stdin);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(f,0,sizeof f);
	f[0]=1;
	for(int i=1;i<=n;i++){
		int l=i,r=i;
		while(l>1&&a[l-1]<a[i]) l--;
		while(r<=n&&a[r+1]<a[i]) r++;
		for(int j=l;j<=r;j++) f[j]+=f[j-1];
	}
	cout<<f[n]<<endl;
	return 0;
}//wa
2022/9/9 23:15
加载中...