题意:有n件商品,每件商品都最多只能被买一次,且有一个原价和一个如果使用优惠券以后可以减少的价格,同时,除了第一件商品以外每件商品都有一个xi属性,表示买这个商品时如果要使用优惠券必须已经使用了xi的优惠券.现在有B的钱,问在不超过B的钱的情况下最多能买多少件商品. 做法:因为根据x属性,所有商品能够被连缀成一棵以1为根节点的树,因此考虑树形dp,因为n=5000,所以定义状态如下:dp[i][j][p],表示从i这件开始买,已经买了j件商品且i这件商品是否已经使用了优惠券(1表示使用,0表示没…