###### cf-Round #216 (Div. 2) -D Valera and Fools-dfs

vis[a][b]: 第一个人为a，第二个人为b的状态。

dfs求解。

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int cnt;
int p[5001];
int s[5001];
int n,m;
int vis[5001][5001];
void dfs(int a,int b,int k)
{
if(k>m)return;
if(a>n)a=n+1;
if(b>n)b=n+1;
if(vis[a][b])return;
vis[a][b]=1;cnt++;
// cout<<a<<" "<<b<<endl;
if(p[a])
{
if(s[b])dfs(b+1,b+2,k+1);
if(s[b]<100)dfs(a,b+1,k+1);
}
if(p[a]<100)
{
if(s[b])dfs(b,b+1,k+1);
}
}
int main()
{
int i;
while(~scanf("%d%d",&n,&m))
{
memset(vis,0,sizeof(vis));
memset(p,0,sizeof(p));
memset(s,0,sizeof(s));
for(i=1;i<=n;i++)
{
scanf("%d",&p[i]);
}
for(i=n;i>=1;i--)
{
s[i]=max(s[i+1],p[i]);
}
cnt=0;
if(n>1)dfs(1,2,0);
else cnt=1;
cout<<cnt<<endl;
}
}


#### Codeforces Round #205 (Div. 2)A

2013-10-27 19:00:46

#### C - Valera and Contest题解

2015-08-06 21:26:22

#### Codeforces Round #216 (Div. 2) B. Valera and Contest

2013-11-30 11:00:45

#### Codeforces Round #216_div2_D.Valera and Fools

2013-12-03 12:00:33

#### Codeforces Round #216 (Div. 2) D. Valera and Fools

2013-11-30 13:21:12

#### Codeforces Round #216 (Div. 2)---C. Valera and Elections

2015-04-07 12:11:17

#### Codeforces Round #258 (Div. 2)-(A,B,C,D,E)

2014-07-25 14:39:48

#### Codeforces Round #444 (Div. 2)-贪心&尺取-Ratings and Reality Shows

2017-11-11 20:11:11

#### codeforces 364 div2 D As Fast As Possible

2016-08-07 19:38:27

#### Codeforces Round #152 (Div. 2) D. Sweets for Everyone!（二分）

2015-08-21 11:35:21

## 不良信息举报

cf-Round #216 (Div. 2) -D Valera and Fools-dfs