题解 | 左侧严格小于计数

左侧严格小于计数

https://www.nowcoder.com/practice/c5922c6cdd1445749bd42f586c422435

import sys

n = int(sys.stdin.readline().strip())
l = list(map(int, sys.stdin.readline().split()))
counts = [0] * 11

for num in l:
    # 计算前面比当前元素小的元素总数
    smaller_count = sum(counts[:num])
    print(smaller_count, end=' ')
    counts[num] += 1

全部评论

相关推荐

12-24 20:52
武汉大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务