changpin_zhze @ 2023-09-02 17:08:29
本地能过,提交就CE,求调
#include<bits/stdc++.h>
using namespace std;
long long ans=0;
long long y,m,d,h,mi;
long long y1,m1,d1,h1,mi1;
long long n,a[5010];
bool run(long long a){
return (a%400==0||a%4==0&&a%100!=0);
}
long long day(long long a,bool run){
if(a==1||a==3||a==5||a==7||a==8||a==10||a==12){
return 31;
}else if(a==2){
if(run)return 29;
return 28;
}else{
return 30;
}
}
long long dateToDay(void){
long long ans=0,ansmin=0;
for(long long i=y;i<y1;i++){
if(run(i)){
ans+=366;
}else{
i+=365;
}
}
for(long long i=1;i<m1;i++){
ans+=day(i,run(y1));
}
ans+=d1;
ansmin+=h1*60+mi1;
for(long long i=1;i<m;i++){
ans-=day(i,run(y));
}
ans-=d;
long long exmin=h*60+mi;
if(ansmin>=exmin){
ansmin-=exmin;
}else{
ans--;
ansmin+=60*24;
ansmin-=exmin;
}
return (ans*24*60+ansmin);
}
int main(){
cin>>n;
for(long long i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
char aa,bb,cc,dd;
cin>>y>>aa>>m>>bb>>d>>cc>>h>>dd>>mi;
cin>>y1>>aa>>m1>>bb>>d1>>cc>>h1>>dd>>mi1;
long long qwq=dateToDay();
long long ans=0;
long long he=0;
for(long long i=0;i<n;i++){
if(he+a[i]<=qwq){
he+=a[i];
ans++;
}else{
cout<<ans;
break;
}
}
return 0;
}
by jqQt0220 @ 2023-09-02 17:28:08
y1 不能用,你改个变量名
by changpin_zhze @ 2023-09-02 17:53:40
@jqQt0220 编译过了,谢谢!