kobe_offical @ 2022-05-15 20:36:55
#include<bits/stdc++.h>
using namespace std;
long long n,day,fen,ans;
int a[5140];
long long y,m,d,h,f,yy,mm,dd,hh,ff;
char q;
bool p(int x){
if(x%100==0){if(x%400==0)return 1;}
else{if(x%4==0)return 1;}
return 0;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
cin>>y>>q>>m>>q>>d>>q>>h>>q>>f;
cin>>yy>>q>>mm>>q>>dd>>q>>hh>>q>>ff;
for(int i=y;i<yy;i++){
if(p(i)==1){
day+=366;
}
else{
day+=365;
}
for(int j=m;j<mm;j++){
if(j==2&&p(i)==1){
day+=29;
}
else if(j==2&&p(i)==0){
day+=28;
}
else if(j==4||j==6||j==9||j==11){
day+=30;
}
else if(j==1||j==3||j==5||j==7||j==8||j==10||j==12){
day+=31;
}
}
}
day=day+dd-d;
fen=(hh-h)*60+ff-f;
fen=fen+day*1440;
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
if(fen>=a[i]){
fen-=a[i];
ans++;
}
}
cout<<ans;
return 0;
}
蒟蒻认为是自己求day时错了 自己调时中间j的循环没有进去
by lihanwen12 @ 2022-05-15 21:12:55
@Iihanwen12 举个例子:
2
1
1
2007-12-31-23:59
2008-01-01-00:00
输出天、分钟出来看看吓死你