0
已解决
陆麟瑞
资深天翼
资深天翼
这是我的错误代码(WA两个点):
#include <bits/stdc++.h>
using namespace std;
int a[100000];
int pd2(int m)
{
if(m%400==0||m%4==0&&m%100!=0)
{
return 29;
}
return 28;
}
int pd(int n,int m)
{
if(n==4||n==6||n==9||n==11) return 30;
else if(n==2) return pd2(m);
return 31;
}
int main()
{
int year,month,day,d,e,year1,month1,day1,d1,e1,ans=0,n,ans1=0;
char x1,x2,x3,x4;
cin>>n;
for(int i=1; i<=n; i++)
cin>>a[i];
cin>>year>>x1>>month>>x2>>day>>x3>>d>>x4>>e;
cin>>year1>>x1>>month1>>x2>>day1>>x3>>d1>>x4>>e1;
while(year!=year1||month!=month1||day!=day1)
{
day++;
ans++;
if(day>pd(month,year))
{
day=1;
month++;
if(month>12)
{
month=1;
year++;
}
}
}
sort(a+1,a+n+1);
ans1=d1*60+e1-(d*60+e);
ans=ans*1440+ans1;
ans++;
int total=0;
for(int i=1; i<=n; i++)
{
total+=a[i];
if(total>ans)
{
cout<<i-1;
return 0;
}
}
cout<<n;
}