60pts

P1167 刷题

Mr_ll @ 2022-11-16 17:57:11

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#define ll long long
using namespace std;
const int N=5e3+10,M=1e5+10;
int n,t[N];
int yu[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
ll sum,su;
ll read() {
    ll x=0,f=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    while(ch>='0'&&ch<='9')
        x=(x<<3)+(x<<1)+(ch^48),
        ch=getchar();
    return x*f;
}
bool cmp(int a,int b) {
    return a<b;
}
bool prun(int i){
    if(((i%4==0)&&(i%100!=0))||i%400==0) return 1;
    return 0;
}
ll Q(int nian,int yue,int ri,int shi,int fen) {
    ll s=0,a,b;
    a=525600;b=527040;
    for(int i=0;i<nian;i++) {
        if(prun(i)) s+=a;
        else s+=b;
    }
    a=1440;
    for(int i=1;i<yue;i++) {
        s+=yu[i]*a;
        if(prun(nian)&&i==2) s+=a;  
    }
    s+=(ll)(ri-1)*a;
    a=60;
    s+=(ll)shi*a;
    s+=(ll)fen;
    return s;
}
ll get() {
    char ch=getchar();
    int nian,yue,ri,shi,fen;
    nian=yue=ri=shi=fen=0;
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') nian=(nian<<3)+(nian<<1)+(ch^48),ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') yue=(yue<<3)+(yue<<1)+(ch^48),ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') ri=(ri<<3)+(ri<<1)+(ch^48),ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') shi=(shi<<3)+(shi<<1)+(ch^48),ch=getchar();
    while(ch<'0'||ch>'9') ch=getchar();
    while(ch>='0'&&ch<='9') fen=(fen<<3)+(fen<<1)+(ch^48),ch=getchar();
    return Q(nian,yue,ri,shi,fen);
}
int main() {
    n=read();
    for(int i=1;i<=n;i++) t[i]=read();
    sort(t+1,t+1+n,cmp);
    sum=get()-get();
    sum=0-sum;
    for(int i=1;i<=n;i++) {
        su+=t[i];
        if(su>sum) {
            printf("%d\n",i-1);
            break;
        }
    }
    return 0;
} 

谢谢


|