• [模拟] P1167 刷题


    日期模拟好像一直很弱

    敲了好久

    bool ly(int x) //leapyear
    {
        return ( (x % 4 == 0 && x % 100 != 0) || x % 400 == 0);
    }
    
     if(ly(ya))    //leapyear month
                month[2] = 29;
            else
                month[2] = 28;
    
    if(ly(ya))    //sum of leapyear days
                sum += 24 * 60 * 366;
            else
                sum += 24 * 60 * 365;
    //#pragma GCC optimize(2)
    #include <cstdio>
    #include <iostream>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <string>
    #include <cstring>
    #include <algorithm>
    #include <stack>
    #include <queue>
    #include <set>
    #include <map>
    #include <ctime>
    #include <vector>
    #include <fstream>
    #include <list>
    #include <iomanip>
    #include <numeric>
    using namespace std;
    typedef long long ll;
    
    const int MAXN = 1e6 + 10;
    
    int arr[MAXN];
    
    int month[13] = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    
    bool ly(int x)
    {
        return ( (x % 4 == 0 && x % 100 != 0) || x % 400 == 0);
    }
    
    int main()
    {
        //ios::sync_with_stdio(false);
    
        //cin.tie(0);     cout.tie(0);
    
        int N, ans = 0;
        
        cin>>N;
    
        for(int i = 0; i < N; i++)
            scanf("%d", &arr[i]);
    
        sort(arr, arr + N);
    
        int ya, yb, ma, mb, da, db, ha, hb, mia, mib;
    
        char cu;
    
        cin>>ya>>cu>>ma>>cu>>da>>cu>>ha>>cu>>mia;
    
        cin>>yb>>cu>>mb>>cu>>db>>cu>>hb>>cu>>mib;
    
        //printf("%d %d %d %d %d
    ", ya, ma, da, ha, mia);
    
        ll sum = 0, tdm = (hb * 60 + mib) - (ha * 60 + mia);
    
        while(ya < yb - 1)
        {
            if(ly(ya))
                sum += 24 * 60 * 366;
            else
                sum += 24 * 60 * 365;
            ya++;
        }
    
        while( !(ya == yb && ma == mb && da == db) )
        {
            sum += 24 * 60;
    
            if(ly(ya))
                month[2] = 29;
            else
                month[2] = 28;
    
            da++;
    
            if(da == month[ma] + 1)
            {
                ma++;
                da = 1;
            }
    
            if(ma == 13)
            {
                ya++;
                ma = 1;
            }
        }
    
        sum += tdm;
    
        //cout<<sum<<endl;
    
        for(int i = 0; i < N; i++)
        {
            sum -= arr[i];
    
            if(sum >= 0)
                ans++;
            else
                break;
        }
    
        cout<<ans<<endl;
    
        return 0;
    }
    /*
    2
    1
    1
    2007-06-22-12:40
    2007-06-23-12:00
    */
  • 相关阅读:
    AC自动机学习笔记(模板)
    codeforces1328E
    Codeforces 1288E- Messenger Simulator (树状数组)
    线性基小记
    HDU3949
    矩阵快速幂小记
    5E
    5D
    5C
    5B
  • 原文地址:https://www.cnblogs.com/zeolim/p/12270466.html
Copyright © 2020-2023  润新知