There are currently 4 posts.
Font size: Small - 100% (Default)  Content converter: No conversion
 
Clicks Replies
223 3
园艺
初级魔法师 五级
Reply
Floor 1 Posted at: 3/24/26 21:59
初级魔法师 五级
Reply
Floor 2 Posted at: 3/24/26 22:02
需要满足

多端可能开始

固定长度间隔

高度依次递增

初级魔法师 五级
Reply
Floor 3 Posted at: 3/24/26 22:13
解决方案

枚举长度间隔

默认所有位置开始,长度为1

在开始位置后的长度判断,从该点逆推,记录到该点的可用长度

在记录长度时候同时和已知的最大长度比较

初级魔法师 五级
Reply
Floor 4 Posted at: 3/24/26 22:29

import os

import sys


# 请在此输入您的代码

n=int(input())

trees=[0]+list(map(int,input().split()))

max_r=1

for d in range(1,n+1):

  p=[1]*(n+1)

  for i in range(d+1,n+1):

    if trees[i]>trees[i-d]:

      p[i]=p[i-d]+1

      if p[i]>max_r:

        max_r=p[i]

print(max_r)

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
(Shortcut key: Ctrl+Enter)
Post Information
Clicks: 223 Replies: 3
Author:
Last reply:
Last reply time: 3/24/26 22:29
Announcements