Python求助,WA on #5,6
  • 板块P1167 刷题
  • 楼主MC_xjhjdA
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/20 10:13
  • 上次更新2025/1/20 10:35:40
查看原帖
Python求助,WA on #5,6
1227790
MC_xjhjdA楼主2025/1/20 10:13
import re
n=int(input())
l=sorted([int(input()) for _ in range(n)])
to=0
year1,month1,day1,hour1,minute1=map(int,re.split(' |\-|\:',input()))
year2,month2,day2,hour2,minute2=map(int,re.split(' |\-|\:',input()))
ru=lambda x:1 if((x%4==0 and x%100!=0)or(x%400==0)) else 0
def mo(mon,flag):
    if mon in [1,3,5,7,8,10,12]:return 31
    else:
        if mon==2:
            if flag:return 29
            else:return 28
        else:return 30
to_day1,to_day2=day1,day2
for x in range(year1):
    to_day1+=365+ru(x)
for x in range(year2):
    to_day2+=365+ru(x)
for x in range(1,month1+1):
    fl=ru(year1)
    to_day1+=mo(x,fl)
for x in range(1,month2+1):
    fl=ru(year2)
    to_day2+=mo(x,fl)
time=to_day2*1440+hour2*60+minute2-(to_day1*1440+hour1*60+minute1)
for x in l:
    if time-x<0:
        break
    time-=x
    to+=1
print(to)
2025/1/20 10:13
加载中...