Tsumi @ 2019-01-05 17:42:43
#include<bits/stdc++.h>
using namespace std;
bool fun(int x){
if(x%100==0){if(x%400==0)return 1;}
else{if(x%4==0)return 1;}
return 0;
}
int main(){
int n;
int sum=0;
long long ssum=0;
cin>>n;
int a[5010]={0};
int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
for(int i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
int year,month,day,hour,minute;
int year1,month1,day1,hour1,minute1;
long long year2,month2,day2,hour2,minute2;
scanf("%d-%d-%d-%d:%d",&year,&month,&day,&hour,&minute);
scanf("%d-%d-%d-%d:%d",&year1,&month1,&day1,&hour1,&minute1);
year2=year1-year;
month2=month1-month;
day2=day1-day;
hour2=hour1-hour;
minute2=minute1-minute;
if(year2>0){
month2+=year2*12;
}
if(month2>0){
int i=month,j=year;
for(int o=0;o<month2;o++){
if(i>12){
i-=12;
j++;
}
if(i==1&& fun(j)==0){
day2+=m[i-1]+1;
i++;
continue;
}
day2+=m[i-1];
i++;
}
}
if(day2>0){
hour2+=day2*24;
}
if(hour2>0){
minute2+=hour2*60;
}
for(int i=0;i<n;i++){
if(minute2-a[i]>=0 && a[i]!=0){
minute2-=a[i];
sum++;
}
}
cout<<sum;
return 0;
}
第八个点和第十个点,貌似最后一位数都少了1?
by Mevinsp @ 2019-11-09 10:54:10
希望更丰富的展现?使用Markdown 发表回复