Cute_QiQi @ 2025-01-01 11:43:12
WA on 5、6、8
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, a[5005], sy, ey, sm, em, sd, ed, sh, eh, st, et, t, tot;
int w(string s, int l, int r)
{
int m=0;
for(int i=l; i<r; ++i) m=m*10+s[i]-'0';
return m;
}
int r(int m)
{
return m%400==0||m%4==0&&m%100!=0;
}
signed main(){
ios::sync_with_stdio(), cin.tie(0), cout.tie(0);
cin>>n;
for(int i=1; i<=n; ++i) cin>>a[i];
string s, e; cin>>s>>e;
sy=w(s, 0, 4), ey=w(e, 0, 4);
sm=w(s, 5, 7), em=w(e, 5, 7);
sd=w(s, 8, 10), ed=w(e, 8, 10);
sh=w(s, 11, 13), eh=w(e, 11, 13);
st=w(s, 14, 16), et=w(e, 14, 16);
for(int i=sy; i<ey; ++i) t+=365+r(i);
t-=r(sy)&&sm>2, t+=r(ey)&&em>2;
t=24*60*(t-sd+ed)-60*sh+60*eh-st+et;
stable_sort(a+1, a+n+1);
for(int i=1; i<=n; ++i)
{
if(t>=a[i]) t-=a[i], ++tot;
else break;
}
cout<<tot;
return 0;
}
by xhg20121012 @ 2025-01-08 20:17:14
joker