题解 | #降温(hard)#

降温(hard)

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

快速IO,然后用if-else分别模拟求出最大最小值即可

from sys import stdin, stdout
def main():
    input = stdin.readline
    n,x = map(int,input().split())
    if n == 1:
        print("0 0")
        return
    l = [int(i) for i in input().split()]
    cntmax = 0
    cntmin = 0
    # cntmax
    if l[0] != -999999999:
        start = l[0]
    else:
        start = 500000000
    for i in range(1,n):
        if l[i] != -999999999:
            if start-l[i] >= x:
                cntmax += 1
            start = l[i]
        else:
            if start-x>= -500000000:
                start -= x
                cntmax += 1
            else:
                start = 500000000
    # cntmin
    if l[0] != -999999999:
        start = l[0]
    else:
        start = -500000000
    for i in range(1,n):
        if l[i] != -999999999:
            if start-l[i] >= x:
                cntmin += 1
            start = l[i]
        else:
            start = max(-500000000,start - x + 1)
    print(cntmax,cntmin)
if __name__ == "__main__":
    main()
全部评论

相关推荐

仁者伍敌:牛子这些人还会点一个自动回复,boss都不带回复的
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
06-27 18:53
门头沟学院 Java
这样才知道自己不适合搞代码,考公去咯
只爱喝白开水:我也发现不适合搞代码,打算转非技术方向了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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