思路:模拟题。根据题意进行模拟即可,可以写一次遍历,我这里写的是两次遍历,看着比较简单
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
m = II()
a = LII()
n = II()
ones1 = cnt1 = 0
for i in range(0, m, 2):
ones1 += a[i]
cnt1 += 1
ones2 = cnt2 = 0
for i in range(1, m, 2):
ones2 += a[i]
cnt2 += 1
if ones1:
print("true" if ones1 + n <= cnt1 else "false")
else:
print("true" if ones2 + n <= cnt2 else "false")
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号