niuniudundun @ 2024-09-08 08:48:25
#include<iostream>
#include<algorithm>
using namespace std;
long long TIME(int y1,int m1,int d1,int h1,int M1,/*||*/int y2,int m2,int d2,int h2,int M2){
long long time=0;
time=abs((M2+h2*60+d2*60*24+m2*60*60*24*28+y2*60*60*24*365)-(M1+h1*60+d1*60*24+m1*60*60*24*28+y1*60*60*24*365));
// cout<<time<<endl;
for(int i=y1;i<y2;i++){
// if(((i%4==0&&i%100!=0)||i%400==0)&&m2>=2) time+=60*60*24;
if((i%4==0&&i%100!=0)||i%400==0) time+=60*60*24;
time+=29*60*60*24;
}
return time;
}
int y1,m1,d1,h1,M1;//y年m月d日h时M分
int y2,m2,d2,h2,M2;//y年m月d日h时M分
const int maxn=5001;
int a[maxn];
int n,ans=0;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+n+1);
scanf("%d-%d-%d-%d:%d",&y1,&m1,&d1,&h1,&M1);
scanf("%d-%d-%d-%d:%d",&y2,&m2,&d2,&h2,&M2);
long long time=TIME(y1,m1,d1,h1,M1,y2,m2,d2,h2,M2);
// cout<<time<<endl;
for(int i=1;i<=n;i++){
if(time-a[i]<0){
break;
}else{
time-=a[i];
ans++;
}
}
cout<<ans<<endl;
return 0;
}
by Retana @ 2024-10-06 22:30:59
给你一个思路
int m[13] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int mr[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};