1 条题解

  • 0
    @ 2024-4-8 19:00:42
    n = int(input())
    ls = [0]*(n+5)
    for i in range(n):
        a,b = map(int,input().split())
        ls[i] = [a,b]
    
    dp = [0]*(n+5)
    
    for i in range(n-1,-1,-1):
        dp[i] = dp[i+1]
        c = i + ls[i][1]+1
        dp[i] = max(dp[i],ls[i][0]+(dp[c] if c<n else 0 ))
    
    print(max(dp))
    
    • 1

    信息

    ID
    127
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    309
    已通过
    73
    上传者