码迷,mamicode.com
首页 > 其他好文 > 详细

1006 Sign In and Sign Out

时间:2018-11-27 22:17:32      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:stream   ring   pac   splay   strcpy   for   space   src   clu   

水题~

技术分享图片
#include<iostream>
#include<algorithm>
#include<string.h>
#define maxn 25
using namespace std;
typedef long long ll;
char s[maxn],ttime[10];
int maxh=0,maxm=0,maxs=0;
int minh=23,minm=59,mins=59;
int hr,me,sd;
char lockid[maxn],unlockid[maxn];
int main()
{
    int m;
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>s;
        cin>>ttime;
        hr=(ttime[0]-0)*10+(ttime[1]-0);
        me=(ttime[3]-0)*10+(ttime[4]-0);
        sd=(ttime[6]-0)*10+(ttime[7]-0);
        if(hr<minh)
        {
            minh=hr,minm=me,mins=sd;
            strcpy(unlockid,s);
        }
        else if(hr==minh)
        {
            if(me<minm)
            {
                minh=hr,minm=me,mins=sd;
                strcpy(unlockid,s);
            }
            else if(me==minm)
            {
                if(sd<mins)
                {
                    minh=hr,minm=me,mins=sd;
                    strcpy(unlockid,s);
                }
            }
        }
        cin>>ttime;
        hr=(ttime[0]-0)*10+(ttime[1]-0);
        me=(ttime[3]-0)*10+(ttime[4]-0);
        sd=(ttime[6]-0)*10+(ttime[7]-0);
        if(hr>maxh)
        {
            maxh=hr,maxm=me,maxs=sd;
            strcpy(lockid,s);
        }
        else if(hr==maxh)
        {
            if(me>maxm)
            {
                 maxh=hr,maxm=me,maxs=sd;
                strcpy(lockid,s);
            }
            else if(me==maxm)
            {
                if(sd>maxs)
                {
                     maxh=hr,maxm=me,maxs=sd;
                    strcpy(lockid,s);
                }
            }
        }

    }
    cout<<unlockid<<" "<<lockid<<endl;
}
View Code

 

1006 Sign In and Sign Out

标签:stream   ring   pac   splay   strcpy   for   space   src   clu   

原文地址:https://www.cnblogs.com/FTA-Macro/p/10029123.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!