CCF 201909-2 小明种苹果(续) python
作者:互联网
'''
测试用例1
4
4 74 -7 -12 -5
5 73 -8 -6 59 -4
5 76 -5 -10 60 -2
5 80 -6 -15 59 0
测试用例2
5
4 10 0 9 0
4 10 -2 7 0
2 10 0
4 10 -3 5 0
4 10 -1 8 0
注意树是围成一个圆的 连续三棵树需要注意
'''
N = int(input())
a = []
e = [0]*N
b = []
for i in range(N):
x = list(map(int, input().split()))
a.append(x[0])
s = x[1]
for j in range(2, len(x)):
if x[j] > 0:
if s > x[j]:
e[i] = 1
elif s == x[j]:
e[i] = 0
s = x[j]
else:
s += x[j]
b.append(s)
T = sum(b)
D = 0
for i in range(N):
if e[i] == 1:
D += 1
E = 0
for i in range(N-2):
if e[i] == 1 and e[i+1] == 1 and e[i+2] == 1:
E += 1
if e[0] == 1 and e[N-2] == 1 and e[N-1] == 1:
E += 1
if e[0] == 1 and e[1] == 1 and e[N-1] == 1:
E += 1
print(T, D, E)
The Kite Runner。
发布了4 篇原创文章 · 获赞 0 · 访问量 74
私信
关注
标签:10,小明种,python,int,range,测试用例,input,CCF,append 来源: https://blog.csdn.net/Mia0717/article/details/104070446