玄关

P1167 刷题

LichKing_Arthas @ 2024-08-17 20:44:22

#include<bits/stdc++.h>
using namespace std;
int ans,a[5005],start[6],end[6],day[13]={0,31,28,31,30,31,30,31,31,30,31,31,30};
bool panding(int x){
    if(x%100==0){if(x%400==0)return 1;}
    else{if(x%4==0)return 1;}
    return 0;
}
int main(){
    int n;cin>>n;
    long long t;
    for(int i=1;i<=n;i++)  cin>>a[i];
    sort(a+1,a+n+1);
    scanf("%d-%d-%d-%d:%d",&start[1],&start[2],&start[3],&start[4],&start[5]);
    scanf("%d-%d-%d-%d:%d",&end[1],&end[2],&end[3],&end[4],&end[5]);
    for(int i=start[1];i<end[1];i++)
       if(panding(i)==1)  t-=366;
       else  t-=365;
    for(int i=1;i<start[2];i++)  t+=day[i];
    for(int i=1;i<end[2];i++)  t-=day[i];
    if(panding(start[1]) && start[2]>2)  t++;
    if(panding(end[1]) && end[2]>2)  t--;
    t+=start[3];
    t-=end[3];
    t*=1440;
    t+=60*start[4]+start[5];
    t-=60*end[4]+end[5];
    t*=-1;
     for(int i=1;i<=n;i++){
        if(t>=a[i])  t-=a[i],ans++;
        else break;//判断能不能刷完这道题
    }
    cout<<ans;//输出
    return 0;
}

by eason7021 @ 2024-08-17 20:45:12


by yeyuhang @ 2024-09-22 14:20:17

??? 你问我我问谁


|