题解 | #鹏#

https://ac.nowcoder.com/acm/problem/17361

首先使用stdin.readline来快读,然后,status = True意味着大鹏之前没有往上飞,当status = False时,如果大鹏往下飞了,则找到了一个山。

from sys import stdin
input = stdin.readline
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
status = True
for i in range(n-1):
    if status:
        if l[i+1] > l[i]:
            status = False
    else:
        if l[i+1] < l[i]:
            status = True
            cnt += 1
print(cnt)
全部评论

相关推荐

感觉今年拿到大厂实习offer的人很多,光是身边同学室友都是好几个offer。由此可见,秋招得有多卷
小浪_Coding:必须卷的起飞, 应该比25更卷一点, 25已经是哀声一片了, 26会更难一点, 现在还有`很多25未找到的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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