何成95
何成95
全部文章
分类
归档
标签
去牛客网
登录
/
注册
何成95的博客
全部文章
(共206篇)
题解 | 最大子段和
n = int(input()) a = list(map(int,input().split())) max_sum, cur_max= a[0], a[0]#最大子数组和,当前累计最大子数组和 for i in range(1,n): cur_max = max(a[i],cur_ma...
2025-10-29
0
10
题解 | 小红的地砖
n = int(input()) a = list(map(int,input().split())) if n==1:#只有一块砖,只有一种行走方式,一次走一步 print(a[n-1]) elif n==2:#只有两块砖,想要省力,只能一次走两步 print(a[n-1]) e...
2025-10-29
0
8
题解 | 小红闯关
import heapq#不用堆队列也可以做,但是会超时 n, k = map(int,input().split()) a = list(map(int,input().split())) total_time = sum(a) pq, saved_time = [], 0 for i in...
2025-10-29
0
8
题解 | 硬币凑钱
n = int(input()) coins = [1,5,7]#所有硬币的集合列表 INF = float('inf')#动态规划列表初始值位无穷大infinity dp = [float(INF)]*(n+1)#动态规划数组列表 dp[0] = 0#想要找零0元,只有0种方式 for coin ...
2025-10-28
0
9
题解 | 数楼梯
n = int(input()) dp = [0]*(n+1) if n==1:#只能一步到顶端,只有一种走法 print(1) elif n==2:#可以两种 print(2) else:#需要进行动态规划 dp[0], dp[1], dp[2] = 0, 1, 2 ...
2025-10-28
0
12
题解 | 小红的整数配对
n, k = map(int,input().split()) a = sorted(list(map(int,input().split()))) #数据输入及初始化 score, i = 0, n-1#分数,序号(从n-1开始) while i>0: if a[i]-a[i-1]&...
2025-10-28
0
10
题解 | 交换到最大
t = int(input()) for _ in range(t): s = list(input()) n = len(s) #从第i未开始固定最有价值的值,任何距离当前位置超过 9 的字符,移动过来的价值都必然是负数 for i in range(n): ...
2025-10-28
0
8
题解 | 小红的矩阵染色
m, n, k = map(int, input().split()) matrix = [input() for _ in range(m)] result = []#求出所有可以染色得分的空格,并存储在列表中降序排列 for j in range(n): cur = 0 for ...
2025-10-28
0
11
题解 | 茉茉的密码
n = int(input()) coms = set(input()) for i in range(n-1): coms = coms.intersection(set(input()))#求交集 print(sorted(list(coms))[0])#单个字母也可以
2025-10-27
0
12
题解 | 最大 FST 距离
#数据输入及初始化 n = int(input()) a = list(map(int, input().split())) #根据变换得到等效公式,求等效公式中的各个项 ad = [a[i]**2+(i+1)**2 for i in range(n)] su = [a[i]**2-(i+1)**2...
2025-10-27
0
12
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页