30分求助

P1167 刷题

2022_37_yzyUUU @ 2023-11-24 17:56:54

1#4#9 AC

2#3 RE

其余WA

#include<bits/stdc++.h>
using namespace std;
int timu[5001],mouth[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,day,hour,minute,year1,month1,day1,hour1,minute1;
long long t=0;
bool run_nian(int k){
    if(k%4==0&&k%100!=0||k%400==0)return 1;
    return 0;
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>timu[i];
    }
    sort(timu+1,timu+n+1);
    scanf("%d-%d-%d-%d:%d",&year,&month,&day,&hour,&minute);
    scanf("%d-%d-%d-%d:%d",&year1,&month1,&day1,&hour1,&minute1);
    for(int i=year;i<year1;i++){
        t+=365*24*60;
        t+=run_nian(i)*24*60;
    }
    for(int i=month;i<month1;i++){
        t+=mouth[i]*24*60;
        if(run_nian(year1))t+=24*60;
    }
    for(int i=day;i<day1;i++){
        t+=24*60;
    }
    int f1=hour*60+minute,f2=hour1*60+minute1;
    t+=f2-f1;
    int i=0;
    while(t>0){
        i++;
        t-=timu[i];
    }
    cout<<i;
}

|