haungyuze114514 @ 2023-12-22 19:18:58
#include <bits/stdc++.h>
using namespace std;
int b[10000];
int daytime[10000];
int dq[100],js[100];
int pinmonth[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int runmonth[20]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int bdn(int gg){
int k;
if(gg%4!=0) k=0;
else if(gg%100==0){
if(gg%400==0) k=1;
else k=0;
}
else k=1;
return k;
}
int main(){
int a,time,dqtime,jstime,day,dqd=0,jsd=0,year=0,endtime;
int dqday,jsday,dqnian,jsnian,dqnian2,jsnian2,nm,tms=0;
string dq2,js2;
cin>>a;
for(int i=1;i<=a;i++) cin>>b[i];
cin>>dq2;
cin>>js2;
for(int i=0;i<16;i++)
dq[i]=dq2[i];
for(int i=0;i<16;i++)
js[i]=js2[i];
dqtime=(dq[11]*10+dq[12])*60+dq[14]*10+dq[15];
jstime=(js[11]*10+js[12])*60+js[14]*10+js[15];
time=jstime-dqtime; //day
dqday=dq[5]*10+dq[6];
jsday=js[5]*10+js[6];
dqnian=dq[0]*1000+dq[1]*100+dq[2]*10+dq[3];
jsnian=js[0]*1000+js[1]*100+js[2]*10+js[3];
dqnian2=bdn(dqnian);
jsnian2=bdn(jsnian);
if(dqnian2=0){
for(int i=1;i<=dqday;i++) dqd+=pinmonth[i];
}
else{
for(int i=1;i<=dqday;i++) dqd+=runmonth[i];
}
if(jsnian2=0){
for(int i=1;i<=jsday;i++) jsd+=pinmonth[i];
}
else{
for(int i=1;i<=jsday;i++) jsd+=runmonth[i];
}
day=(jsd-dqd)*1440; //month
if(jsnian-dqnian!=0){
for(int i=0;i<jsnian-dqnian;i++){
if(bdn(dqnian+i)==0) year+=525600;
else year+=527040;
}
} //year
endtime=year+day+time; //总时间
for(int i=1;i<a;i++){
for(int j=1;j<a;j++){
if(b[j]>b[j+1]){
nm=b[j];
b[j]=b[j+1];
b[j+1]=nm;
}
}
}
for(int i=1;endtime>=0;i++){
if(endtime-b[i]>=0){
endtime-=b[i];
tms++;
}
if(endtime-b[i]<0)
endtime-=b[i];
}
cout<<tms;
return 0;
}
测试点:https://www.luogu.com.cn/record/140552830