蜗牛与飞猪 @ 2023-08-27 17:04:47
O(2^n)的那种递归
最近在学习怎么打暴力 (骗分),thx大佬们
by Argvchs @ 2023-08-27 17:07:09
@蜗牛与飞猪
by 蜗牛与飞猪 @ 2023-08-27 17:08:57
@Argvchs 知道是知道,不会写呀,我太弱了
by _always_ @ 2023-08-27 17:26:36
#include<bits/stdc++.h>
using namespace std;
const int N=5e3+10;
int n,ans=0;
int a[N];
void dfs(int k,int last,int sum){
if(k>n){
ans=max(ans,sum);
return ;
}
if(a[k]>last) dfs(k+1,a[k],sum+1);
dfs(k+1,last,sum);
return ;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
dfs(1,0,0);
printf("%d\n",ans);
return 0;
}
by _always_ @ 2023-08-27 17:27:13
确实很奇怪
by 蜗牛与飞猪 @ 2023-08-27 17:29:19
@always 谢谢大佬!