Along_Dog @ 2022-06-29 13:53:30
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
bool month[13]={1,1,0,1,0,1,0,1,1,0,1,0,1};
struct days{
int y,m,d,h,mi;
long long sum=0;
}st,en;
int n;
int a[5010];
long long ans=0;
long long t;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
}
sort(a+1,a+n+1);
scanf("%d-%d-%d-%d:%d",&st.y,&st.m,&st.d,&st.h,&st.mi);
scanf("%d-%d-%d-%d:%d",&en.y,&en.m,&en.d,&en.h,&en.mi);
st.sum+=365*24*60*st.y+st.d*24*60+st.h*60+st.mi;
for(int i=1;i<=st.m;++i){
if(i==2){
if((st.y%4==0&&st.y%100!=0)||st.y%400==0) st.sum+=29*24*60;
else st.sum+=28*24*60;
}
else if(!month[i]){
st.sum+=30*24*60;
}
else{
st.sum+=31*24*60;
}
}
en.sum+=365*24*60*en.y+en.d*24*60+en.h*60+en.mi;
for(int i=1;i<=en.m;++i){
if(i==2){
if((en.y%4==0&&en.y%100!=0)||en.y%400==0) en.sum+=29*24*60;
else en.sum+=28*24*60;
}
else if(!month[i]){
en.sum+=30*24*60;
}
else{
en.sum+=31*24*60;
}
}
t=en.sum-st.sum;
for(int i=1;i<=n;++i){
if(t>=a[i]){
t-=a[i];
ans++;
}
else{
break;
}
}
printf("%lld\n",ans);
return 0;
}
//100111001010000000010110011100000
C++