_LighT_ @ 2021-11-02 20:26:55
Rt
by _LighT_ @ 2021-11-02 20:31:10
#include<bits/stdc++.h>
const int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int mark[5001];
inline int isleap(int y){
if(y%400==0) return 1;
if(y%100==0) return 0;
if(y%4==0) return 1;
}
int main(){
int y1,M1,d1,h1,m1;
int y2,M2,d2,h2,m2;
long long t1=0,t2=0,t;
int n,ans=0;
scanf("%d",&n);
for(register int i=1;i<=n;++i)
scanf("%d",&mark[i]);
std::sort(mark+1,mark+n+1);
scanf("%d-%d-%d-%d:%d",&y1,&M1,&d1,&h1,&m1);
scanf("%d-%d-%d-%d:%d",&y2,&M2,&d2,&h2,&m2);
for(register int i=0;i<y1;++i)
t1+=365+isleap(i);
t1+=isleap(y1);
for(register int i=1;i<M1;++i)
t1+=month[i];
t1=((t1+d1)*24+h1)*60+m1;
for(register int i=0;i<y2;++i)
t2+=365+isleap(i);
t2+=isleap(y2);
for(register int i=1;i<M2;++i)
t2+=month[i];
t2=((t2+d2)*24+h2)*60+m2;
t=t2-t1;
// std::cout<<"t:"<<t<<std::endl;
for(register int i=1;i<=n&&t>=mark[i];++i){
t-=mark[i];
++ans;
}
printf("%d",ans);
return 0;
}
by Spasmodic @ 2021-11-02 20:31:13
@LighT ub
by Spasmodic @ 2021-11-02 20:31:55
@LighT isleap 最后面要加一个 return 0,不然是ub
by BurningEnderDragon @ 2021-11-02 20:33:31
@LighT 请提供代码及测试点。
根据经验推测:您可能使用了局部变量而未赋初值,此时它们的初值是内存中原有的垃圾值,而本地和评测机内存中原有的内容不一样,所以运行结果可能不同。
遇到这种情况时,请查看洛谷返回的测试点信息(read xxx, expect xxx),而不是根据本地的运行结果就判断自己的输出正确。
by BurningEnderDragon @ 2021-11-02 20:33:52
好像发晚了(
by _LighT_ @ 2021-11-02 20:34:00
@happyChristmas
非常感谢!的确是这个错误