80pts,help

P1167 刷题

liuyi0905 @ 2023-05-06 17:05:17

#8和#10 \tt\red{WA}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int m[12]={31,28,31,30,31,30,31,31,30,31,30,31},sum,ans;
int n,a[5001],yyyy1,mm1,dd1,hh1,min1,yyyy2,mm2,dd2,hh2,min2;
bool isLeap(int year){
    if(year%400==0||year%100!=0&&year%4==0)return true;
    return false;
}
bool check(int year,int month,int day){
    if(month<1||month>12||day<1)return false;
    if(isLeap(year)&&month==2&&day>29)return false;
    if(day>m[month-1])return false;
    return true;
}
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    scanf("%lld-%lld-%lld-%lld:%lld",&yyyy1,&mm1,&dd1,&hh1,&min1);
    scanf("%lld-%lld-%lld-%lld:%lld",&yyyy2,&mm2,&dd2,&hh2,&min2);
    int time1=yyyy1*10000+mm1*100+dd1,time2=yyyy2*10000+mm2*100+dd2;
    for(int i=time1;i<=time2;i++){
        if(check(i/10000,i/100%100,i%100))sum++;
    }
    sum*=1440;
    int s1=hh1*60+min1,s2=hh2*60+min2;
    sum-=s1+1440-s2;
    for(int i=1;i<=n;i++){
        if(sum>=a[i]){
            ans++;
            sum-=a[i];
        }
    }
    cout<<ans;
    return 0;
}

向大佬求助


by qwerti @ 2023-05-14 13:58:23

@liuyi0905


by 765_432 @ 2023-07-15 15:59:18

@liuyi0905 第一次见作弊者【狗头】


|