func main() { var dfs func(nums []int, preUp, preDown, cur, n int) flag := false dfs = func(nums []int, preUp, preDown, cur, n int) { if flag { return } if cur == n { flag = true return } if nums[cur] > preUp { dfs(nums, nums[cur], preDown, cur+1, n) } if nums[cur] < preDown { dfs(nums, preUp, nums[cur], cur+1, n) } } var T int var n int fmt.Scanf("%d", &;T) for i := 0; i < T; i++ { fmt.Scanf("%d", &;n) nums := make([]int, n) for i := 0; i < n; i++ { fmt.Scanf("%d", &;nums[i]) } flag = false dfs(nums, -1, 501, 0, n) if flag { fmt.Println("Yes") } else { fmt.Println("No") } } } 铁子 我这第一题咋不对啊
点赞 2

相关推荐

牛客网
牛客企业服务