'commit'
This commit is contained in:
31
TangDou/Dfs/DFS6_TouQiuYouXi.cpp
Normal file
31
TangDou/Dfs/DFS6_TouQiuYouXi.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1010;
|
||||
const int INF = 0x3f3f3f3f;
|
||||
int a[N];
|
||||
int n;
|
||||
int cnt;
|
||||
|
||||
/**
|
||||
3
|
||||
130 200 55
|
||||
*/
|
||||
void dfs(int step, int sum, int m) {
|
||||
if (step == n + 1) {
|
||||
cnt = max(cnt, sum);
|
||||
return;
|
||||
}
|
||||
if (m > a[step]) {
|
||||
dfs(step + 1, sum + 1, a[step]);
|
||||
dfs(step + 1, sum, m);
|
||||
} else
|
||||
dfs(step + 1, sum, m);
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i]; // 130 200
|
||||
dfs(1, 0, INF);
|
||||
printf("%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user