0分求调
查看原帖
0分求调
1024296
YYPanda233楼主2024/8/15 23:22

subtask#1 AC subtask#0 前两个点WA,后三个点TLE

代码:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 5005

ll n, a[MAXN], ans;

ll dfs(int index, int maxnum)
{
	if (index >= n) return maxnum;
	
	//cout << index << " " << a[index] << " " << maxnum << "\n";
	if (a[index] <= maxnum) return dfs(index + 1, 0);
	else return max(dfs(index + 1, 0), dfs(index + 1, a[index]));
}

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (ll i = 0 ; i < n ; i++) cin >> a[i];
	ans = dfs(0, 0);
	cout << ans;
	return 0;
}

求佬调一下:(

2024/8/15 23:22
加载中...