阅读理解,模拟(Python)

切题之路

https://www.nowcoder.com/practice/561e3cd99b0d434c8c0a956b7af9797f

思路:阅读理解,模拟。由于两者做题顺序一致,都是从左到右,因此我们就可以从左到右遍历每一题,然后判断两者会不会做这题即可。对于clccle来说,难度<他的预期并且花费时间足够才会做题;对于rqy来说,难度>=他的预期并且花费时间的2倍足够才会做题;难度<他的预期并且花费时间足够才会做题。最终遍历,模拟一遍,输出结果即可

代码:

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 GMI():
    return map(lambda x: int(x) - 1, 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():
    n, t = MII()
    a, b = MII()
    time = LII()
    diff = LII()

    ta = tb = t
    cnta = cntb = 0
    for i in range(n):
        tm, df = time[i], diff[i]
        if df < a and ta >= tm:
            cnta += 1
            ta -= tm
        if df >= b and tb >= 2 * tm:
            cntb += 1
            tb -= 2 * tm
        elif df < b and tb >= tm:
            cntb += 1
            tb -= tm

    print(cnta, cntb)

tt = 1
# t = II()
for _ in range(tt):
    solve()
#每日一题挑战#
全部评论

相关推荐

2025-12-31 14:19
门头沟学院 产品经理
点赞 评论 收藏
分享
2025-12-22 21:12
门头沟学院 Java
码农索隆:看得出来,公司对你挺满意哦。 但是你要结合一下自己的职业发展看下,眼光要放长远了看
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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