45haotong @ 2024-10-23 22:03:55
#include<bits/stdc++.h>
using namespace std;
long long m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
long long z[100010],n,ans;
long long sum1,sum2,sum,a1,a2,b1,b2,c1,c2,d1,d2,e1,e2;
int main()
{
cin>>n;
for (int i=1;i<=n;i++)
{
cin>>z[i];
}
sort(z+1,z+n+1);
string x,y;
cin>>x>>y;
a1=(x[0]-'0')*1000+(x[1]-'0')*100+(x[2]-'0')*10+(x[3]-'0');
b1=(x[5]-'0')*10+(x[6]-'0');
c1=(x[8]-'0')*10+(x[9]-'0');
d1=(x[11]-'0')*10+(x[12]-'0');
e1=(x[14]-'0')*10+(x[15]-'0');
for (int i=0;i<=a1;i++)
{
if ((i%4==0&&i%100!=0)||i%400==0)
m[2]=29;
else
m[2]=28;
if (i<a1)
{
sum1+=(365+(m[2]-28))*24*60;
}
else
{
for (int i=1;i<=b1;i++)
{
if (i<b1)
{
sum1+=m[i]*24*60;
}
else
{
sum1+=(c1-1)*24*60;
sum1+=(d1-1)*60;
sum1+=e1;
}
}
}
}
a2=(y[0]-'0')*1000+(y[1]-'0')*100+(y[2]-'0')*10+(y[3]-'0');
b2=(y[5]-'0')*10+(y[6]-'0');
c2=(y[8]-'0')*10+(y[9]-'0');
d2=(y[11]-'0')*10+(y[12]-'0');
e2=(y[14]-'0')*10+(y[15]-'0');
for (int i=0;i<=a2;i++)
{
if ((i%4==0&&i%100!=0)||i%400==0)
m[2]=29;
else
m[2]=28;
if (i<a1)
{
sum2+=(365+(m[2]-28))*24*60;
}
else
{
for (int j=1;j<=b2;j++)
{
if (j<b2)
{
sum2+=m[j]*24*60;
}
else
{
sum2+=(c2-1)*24*60;
sum2+=(d2-1)*60;
sum2+=e2;
}
}
}
}
sum=sum2-sum1;
for (int i=1;i<=n;i++)
{
if (sum>=z[i])
{
ans++;
sum-=z[i];
}
else
{
break;
}
}
cout<<ans;
}
by 45haotong @ 2024-10-23 22:04:28
错了#6#7#8#10