n =int(input())
L =[]for i inrange(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 inrange(n):
ans += L[i][0]+tmp
tmp += L[i][1]print(ans)
2.本质上升序列
代码
s = "tocyjkdzcieoiodfpbgcncsrjbhmugdnojjddhllnofawllbhf\
iadgdcdjstemphmnjihecoapdjjrprrqnhgccevdarufmliqij\
gihhfgdcmxvicfauachlifhafpdccfseflcdgjncadfclvfmad\
vrnaaahahndsikzssoywakgnfjjaihtniptwoulxbaeqkqhfwl"
dp =[1]*200for i inrange(200):for j inrange(i):if s[i]> s[j]:
dp[i]+= dp[j]elif s[i]== s[j]:
dp[i]-= dp[j]print(sum(dp))
多个线程交替打印ABC package 多个线程交替打印ABC;import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;/*** Created with IntelliJ IDEA.** Author: AlenXu* Date: 2024/03/20/10:10* Description:*/
public class ThreadLoopP…