zoukankan      html  css  js  c++  java
  • [模拟] 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
    */
  • 相关阅读:
    服务器操作nginx相关操作命令
    git使用命令
    超出隐藏显示
    微信小程序清除默认样式
    程序员提升之排查bug的能力
    call和apply的基本用法与区别
    vuejs 插件开发并发布到npm--(3)vue组件开发并发布
    vuejs 插件开发并发布到npm--(2)js插件开发
    vuejs 插件开发并发布到npm--(1)为什么要进行插件开发管理
    双机热备份和负载均衡的区别
  • 原文地址:https://www.cnblogs.com/zeolim/p/12270466.html
Copyright © 2011-2022 走看看