Lvyuze @ 2021-11-07 21:19:29
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int ans,n,a[5010],a1[11],b1[11],day[3][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
long long sum;
bool run(int a){
if(a%100==0){
if(a%400) return 1;
else return 0;
}
else{
if(a%4==0) return 1;
else return 0;
}
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
scanf("%d-%d-%d-%d:%d",&a1[1],&a1[2],&a1[3],&a1[4],&a1[5]);
scanf("%d-%d-%d-%d:%d",&b1[1],&b1[2],&b1[3],&b1[4],&b1[5]);
int y=a1[1],m=a1[2],d=a1[3],h=a1[4],s=a1[5];
bool runnian=false;
while(1){
if(y==b1[1]&&m==b1[2]&&d==b1[3]&&h==b1[4]&&s==b1[5]) break;
sum++;
s++;
if(s>60){
s=0;
h++;
}
if(h>60){
h=0;
d++;
}
if(run(y)){
if(d>day[1][m]){
d=1;
m++;
}
}
else{
if(d>day[0][m]){
d=1;
m++;
}
}
if(m>12){
m=1;
y++;
}
}
sort(a+1,a+n+1);
//cout<<sum<<endl;
for(int i=1;i<=n;i++){
if(sum>=a[i]){
sum-=a[i];
ans++;
}
else break;
}
printf("%d",ans);
return 0;
}