Terryhalk_chester @ 2021-03-08 15:45:17
#include<bits/stdc++.h>
using namespace std;
int check(int o){
if(o%4==0&&o%100!=0||o%400==0)return 1;
else return 0;
}
int Check(int a1,int a2,int a3,int a4,int a5,int b1,int b2,int b3,int b4,int b5){
if(a1>b1||a1==b1&&a2>b2||a1==b1&&a2==b2&&a3>b3||
a1==b1&&a2==b2&&a3==b3&&a4>b4||
a1==b1&&a2==b2&&a3==b3&&a4==b4&&a5>b5)return 1;
else return 0;
}
int p[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int k[5010],a[10],b[10];
int main(){
int n,i,j,z=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&k[i]);
scanf("%d-%d-%d-%d:%d",&a[1],&a[2],&a[3],&a[4],&a[5]);
scanf("%d-%d-%d-%d:%d",&b[1],&b[2],&b[3],&b[4],&b[5]);
sort(k+1,k+n+1);
for(i=1;i<=n;i++){
if(check(a[1]))p[2]=29;
else p[2]=28;
a[5]+=k[i];
if(a[5]>=60){
a[4]+=a[5]/60;
a[5]%=60;
}
if(a[4]>=24){
a[3]+=a[4]/24;
a[4]%=24;
}
if(a[3]>p[a[2]]){
a[3]%=(p[a[2]]+1);
a[2]++;
}
if(a[2]>=13){
a[1]++;
a[2]=1;
}
if(Check(a[1],a[2],a[3],a[4],a[5],b[1],b[2],b[3],b[4],b[5]))break;
z++;
}
cout<<z;
}
by Terryhalk_chester @ 2021-03-08 15:47:01
在线等