Typical_typhoon @ 2023-12-03 20:43:11
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=0x3f3f3f;
int n;
int a[5010];
int s[11],e[11];
char c;
bool run(int y){
if(y%100==0&&y%400==0){
return 1;
}
if(y%100!=0&&y%4==0){
return 1;
}
return 0;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ym,yy;
cin>>s[1]>>c>>s[2]>>c>>s[3]>>c>>s[4]>>c>>s[5];
cin>>e[1]>>c>>e[2]>>c>>e[3]>>c>>e[4]>>c>>e[5];
yy=e[1];ym=e[2];
int all=0;
if(e[5]-s[5]<0){
e[4]-=1;
e[5]+=60;
}
all+=e[5]-s[5];
if(e[4]-s[4]<0){
e[3]-=1;
e[4]+=24;
}
all+=(e[4]-s[4])*60;
if(e[3]-s[3]<0){
e[2]-=1;
e[3]+=24;
}
int jw=1;
if(ym==1||ym==3||ym==5||ym==7||ym==8||ym==10||ym==12){
jw=31;
}else if(ym==2){
if(run(yy)){
jw=29;
}else jw=28;
}else jw=30;
all+=(e[2]-s[2])*60*jw;
int k;
if(run(yy)){
k=366;
}else k=365;
all+=(e[1]-s[1])*60*jw*k;
sort(a+1,a+n+1);
int sum=0;
for(int i=1;i<=n;i++){
if(all-a[i]>=0){
sum++;
all-=a[i];
}else break;
}
cout<<sum;
return 0;
}
by Robin_Yhj @ 2023-12-03 20:58:23
run里面和判断错了
by 13245zy @ 2023-12-04 18:40:40
@NB26 这题用线段树(哈哈哈)
by Typical_typhoon @ 2023-12-05 16:01:14
@13245zy kkk
by Typical_typhoon @ 2023-12-07 20:17:00
@Eric__yang 哪里错了
by Chenyufeng040525 @ 2024-03-18 01:32:23
@Typical_typhoon
从天到年转为分钟都有问题,就比如天数+=24是什么东西,建议先都转为天再变为分钟,稍微认真点就行。