50分求调

P1167 刷题

DRheEheAM__Venti @ 2024-07-26 21:34:39

记录

4 WA 1 RE (QAQ

dalao求调

#include<bits/stdc++.h>
using namespace std;
#define int long long
int y,m,d,h,mi,y2,m2,d2,h2,mi2;
int n,t[6000];
int mx,mxn=1;
bool year(int yr){
    return (yr%4==0&&yr%100==0)||(yr%400==0);
}
int intmy(int y){
    int a=0;
    for(int i=0;i<=y;i++){
        if(year(y)) a+=24*60;
        a+=24*60*365;
    }
    return a;
}
int intime(int y,int m,int d,int h,int mi){
    int mth[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int mt=mi;
    mt+=h*60+d*24*60;
    if(year(y)) mth[2]++;
    for(int i=1;i<m;i++) mt+=mth[i]*24*60;
    return mt+intmy(y);
}
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>t[i];
    sort(t+1,t+n+1);
    scanf("%d-%d-%d-%d:%d\n",&y,&m,&d,&h,&mi);
    scanf("%d-%d-%d-%d:%d\n",&y2,&m2,&d2,&h2,&mi2);
    int mti=intime(y2,m2,d2,h2,mi2)-intime(y,m,d,h,mi);
    while(mx<mti) mx+=t[mxn++];
    cout<<--mxn<<endl;
    return 0;
}

|