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 # ans为发消息时刻,tmp为前一个人的总用时 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))