zoukankan      html  css  js  c++  java
  • HDU 4509 湫湫系列故事——减肥记II (简单模拟)

    题意:一天一共有1440分钟,主人公每天有n件事要做,给出这n件事开始跟结束的时间,然后让你求出,空闲的时间的总分钟数是多少。

    解题报告:简单模拟,只要开个一维数组标记那个每个分钟是否是有事的就可以了,有事的每次输入都标记掉就可以了。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 #include<algorithm>
     5 using namespace std;
     6 
     7 bool flag[2000];
     8 int trans(int x,int y)
     9 {
    10     return 60 * x + y;
    11 }
    12 
    13 int main()
    14 {
    15     int n;
    16     while(scanf("%d",&n)!=EOF)
    17     {
    18         memset(flag,0,sizeof(flag));
    19         int sx,sy,ex,ey;
    20         for(int i = 0;i < n;++i)
    21         {
    22             scanf("%d:%d %d:%d",&sx,&sy,&ex,&ey);
    23             int t_e = trans(ex,ey);
    24         //    printf("%d     %d
    ",trans(sx,sy),t_e);
    25             for(int j = trans(sx,sy);j < t_e;++j)
    26             flag[j] = 1;
    27         }
    28         int tot = 0;
    29         for(int i = 0;i < 1440;++i)
    30         tot += (!flag[i]);
    31         printf("%d
    ",tot);
    32     }
    33     return 0;
    34 }
    View Code
  • 相关阅读:
    Docker ntpdate Permition error
    Sublime+Golang Plugin
    顺序表和链表的区别
    Python 性能优化——对象绑定
    Fix git 提交代码错误
    UVa 10523
    UVa 10551
    UVa 10814
    UVa 10925
    Practice Round China New Grad Test 2014 报告
  • 原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3603272.html
Copyright © 2011-2022 走看看