dp,先将材料按以终点为关键字升序排 设f[i,j]为过山车到建到位置i在用了j元钱所得到的最大价值,然后 ..] of longint; f:..,..] of longint; l,n,k,m,j,i,ans:longint; function max(a,b:longint):longint; begin if a>b then exit(a) else exit(b); end; procedure swap(var a,b:longint); var c:longint; begin…