酷尔


私信TA

用户名:kuer

访问量:738

签 名:

等  级
排  名 20177
经  验 661
参赛次数 1
文章发表 2
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

递增三元组
浏览:102

解题思路:
前缀和形式
注意事项:

参考代码:

# 前缀和
n=int(input())
als=list(map(int,input().split()))
bls=list(map(int,input().split()))
cls=list(map(int,input().split()))
ac=[]
cc=[]

temp=[0]*(max(max(als),max(bls))+1)

# 初始化每个数的数量
for i in als:
    temp[i]+=1
# 求每个数数量的前缀和
for i in range(1,max(als)+1):
    temp[i]=temp[i-1]+temp[i]
# 遍历b列表
for i in bls:
    # 由于是大于,并不是大于等于,所以统计到上一个数即可
    ac.append(temp[i-1])

temp=[0]*(max(max(cls),max(bls))+2)
# 初始化每个数的数量
for i in cls:
    temp[i]+=1
# 求每个数数量的后缀和
for i in range(max(cls)-1,0,-1):
    temp[i]=temp[i+1]+temp[i]
# 遍历b列表
for i in bls:
    # 由于是大于,并不是大于等于,所以统计到上一个数即可
    cc.append(temp[i+1])

ans=0
for i in range(len(ac)):
    ans+=ac[i]*cc[i]

print(ans)


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区