1.答疑

代码
n = int(input())
L = []
for i in range(n):a,b,c = map(int,input().split())A = a+b B = a+b+c L.append([A,B])
L.sort(key=lambda x:x[1])
ans = tmp = 0
for i in range(n):ans += L[i][0]+tmptmp += L[i][1]
print(ans)
2.本质上升序列

代码
s = "tocyjkdzcieoiodfpbgcncsrjbhmugdnojjddhllnofawllbhf\
iadgdcdjstemphmnjihecoapdjjrprrqnhgccevdarufmliqij\
gihhfgdcmxvicfauachlifhafpdccfseflcdgjncadfclvfmad\
vrnaaahahndsikzssoywakgnfjjaihtniptwoulxbaeqkqhfwl"
dp = [1]*200
for i in range(200):for j in range(i):if s[i] > s[j]:dp[i] += dp[j]elif s[i] == s[j]:dp[i] -= dp[j]
print(sum(dp))