wangzeyu @ 2020-01-27 21:01:41
#include<assert.h>
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
unsigned daysNum[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};
class Calender {
private :
unsigned year,month,day,hour,minute,second;
public :
static const unsigned long long a_minute=60ull,a_hour=a_minute*60ull,a_day=a_hour*24ull;
void CalenderWrite(unsigned ye=0u,unsigned mo=1u,unsigned da=1u,unsigned ho=0u,unsigned mi=0u,unsigned se=0u) {
this->year=ye;
this->month=mo;
this->day=da;
this->hour=ho;
this->minute=mi;
this->second=se;
return;
}
// void init(void){
// daysNum[0]=0;
// daysNum[1]=31;
// daysNum[2]=0;
// daysNum[3]=31;
// daysNum[4]=30;
// daysNum[5]=31;
// daysNum[6]=30;
// daysNum[7]=31;
// daysNum[8]=31;
// daysNum[9]=30;
// daysNum[10]=31;
// daysNum[11]=30;
// daysNum[12]=31;
// return;
// }
bool is_runnian(void) {
if(this->year%400==0) {
return true;
}
else {
if(this->year%100==0) {
return false;
}
else if(this->year%4==0) {
return true;
}
else return false;
}
}
unsigned getDaysInMonth(void) {
assert(this->month>=1&&this->month<=12);
if(this->month!=2u) {
return daysNum[this->month];
}
else {
if(this->is_runnian()) return 29u;
else return 28u;
}
}
unsigned long long getStandardTime(void) {
unsigned long long res=0ull;
for(unsigned y=0;y<this->year;y++) {
if(this->is_runnian()) {
res+=a_day*366ull;
}
else {
res+=a_day*365ull;
}
}
for(unsigned m=1;m<this->month;m++) {
cerr<<"month="<<this->month<<endl;
res+=this->getDaysInMonth()*a_day;
}
for(unsigned d=1;d<this->day;d++) {
res+=a_day;
}
for(unsigned h=0;h<this->hour;h++) {
res+=a_hour;
}
for(unsigned m=0;m<this->minute;m++) {
res+=a_minute;
}
res+=this->second;
return res;
}
};
Calender begin,end;
const unsigned MAXN=5000+5;
unsigned n,ans;
unsigned long long timeLeft=0;
unsigned list[MAXN];
signed main() {
// begin.CalenderWrite(2000,1,1,0,0,0);
// end.CalenderWrite(2000,1,1,1,1,0);
// cout<<end.getStandardTime()-begin.getStandardTime();
scanf("%u",&n);
for(unsigned i=0u;i<n;i++) {
scanf("%u",&list[i]);
}
sort(list,list+n);
unsigned temp=0;
for(unsigned i=0u;i<n;i++) {
temp+=list[i];
cerr<<"i="<<i<<' '<<list[i]<<' '<<temp*60<<endl;
}
unsigned a,b,c,d,e;
scanf("%u-%u-%u-%u:%u",&a,&b,&c,&d,&e);
begin.CalenderWrite(a,b,c,d,e);
scanf("%u-%u-%u-%u:%u",&a,&b,&c,&d,&e);
end.CalenderWrite(a,b,c,d,e);
timeLeft=end.getStandardTime()-begin.getStandardTime();
cerr<<"delta="<<timeLeft<<endl;
timeLeft/=60ull;
for(unsigned i=0u;i<n;i++) {
if(list[i]<=timeLeft) {
timeLeft-=list[i];
ans++;
}
else {
break;
}
}
// begin.CalenderWrite(2000,7,0,0,0,0);
// cout<<begin.is_runnian()<<endl;
// cout<<begin.getStandardTime()<<endl;
// cout<<end.getStandardTime()<<endl;
// cout<<end.getStandardTime()-begin.getStandardTime()<<endl;
printf("%u",ans);
return 0;
}
5号测试点好像有问题
2007-02-05-00:00~~~
2007-03-28-00:00
应该是51天,日历应该没有问题,但是跟踪调试的结果和答案不一样
by cmll02 @ 2020-01-27 21:06:47
一天从
by wangzeyu @ 2020-01-27 21:15:28
@shygo_cmll02 什么意思
by wangzeyu @ 2020-01-27 21:16:38
@shygo_cmll02 如果数据没有问题,那么问题在哪里
by cmll02 @ 2020-01-27 21:19:24
到2007-03-27-23:59为止是51天,2007-03-28-00:00要记录新的一天
by wangzeyu @ 2020-01-27 21:20:06
可是这新的一天只有一秒
by cmll02 @ 2020-01-28 14:48:09
第五个点你贴一下