1.https://codeforces.com/contest/2033/problem/B
这道题对每个测试样例一个矩阵,求最小次数,观察规律知道只要求最小值的和即可。代码如下:
for _ in range(int(input())):
n = int(input())
mp = [list(map(int,input().split())) for _ in range(n)]
s = 0
for d in range(-n+1,n):
mm = min(mp[i][i-d] for i in range(max(0,d),min(n,n+d)))
if mm < 0:
s += abs(mm)
print(s)
找到对角线的元素特点,mp[i][i-d]都可以想到,主要是后面的索引值要取正确,否则会错。
2.https://codeforces.com/contest/2033/problem/C