• [模拟] 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
    */
  • 相关阅读:
    寻找SQL注入点
    根域名服务器
    Solr 文章集成
    Android事件分发机制
    王自如与老罗的辩论赛谁赢了?!
    ACdream原创群赛(13)のwuyiqi退役专场 C True love
    使用JS对select标签进行联动选择
    c++代码赏析之类对象传參
    基因治疗的现状
    解决手机訪问站点时总体相对屏幕缩小问题?(已解决)
  • 原文地址:https://www.cnblogs.com/zeolim/p/12270466.html
Copyright © 2020-2023  润新知