ECNUAT_LZX @ 2023-01-06 22:28:55
#include<bits/stdc++.h>
using namespace std;
long long runyue[]={0,0,31,60,90,121,151,182,213,243,274,304,335};//第几月的总天数
long long pingyue[]={0,0,31,59,89,120,150,181,212,242,273,303,334};
bool judge_run(long long year){
if(year%4==0&&year%100!=0||year%400==0)return 1;
return 0;
}
signed main(){
long long n,a[5005]={},y1,m1,d1,h1,mi1,y2,m2,d2,h2,mi2,fen1=0,fen2=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> a[i];
}
sort(a,a+n);
scanf("%lld-%lld-%lld-%lld:%lld",&y1,&m1,&d1,&h1,&mi1);
scanf("%lld-%lld-%lld-%lld:%lld",&y2,&m2,&d2,&h2,&mi2);
bool run1=judge_run(y1),run2=judge_run(y2);
if(run1)fen1+=y1*366*24*60;
else fen1+=y1*365*24*60;
if(run2)fen2+=y2*366*24*60;
else fen2+=y2*365*24*60;
if(run1)fen1+=runyue[m1]*24*60;
else fen1+=pingyue[m1]*24*60;
if(run2)fen2+=runyue[m2]*24*60;
else fen2+=pingyue[m2]*24*60;
fen1+=d1*24*60+h1*60+mi1;
fen2+=d2*24*60+h2*60+mi2;
long long fen3=abs(fen2-fen1),ans=0;
cout << fen3 << endl;
for(int i=0;i<n&&fen3>0;i++){
if(fen3==0)break;
if(a[i]<=fen3){
ans++;
fen3-=a[i];
}
else{
break;
}
}
cout << ans;
return 0;
}