[PAT]1006. Sign In and Sign Out (25)
来源:互联网 发布:房屋租赁哪个软件 编辑:程序博客网 时间:2024/05/19 22:03
题目
简单来说就是,输入某个id,以及对应的来的时间,和走的时间,找出最早来的人和最晚走的人,输出他们的id
思路
- 时间的判断可以统一换算成秒来比较大小
- 记录峰值的id和时间,每次读取的时候更新,最后输出即可
代码
#include <stdio.h>#include <iostream>#include <cstring>using namespace std;int main(){ int n; string s; int h1,h2,m1,m2,s1,s2,t1,t2; char no; string ins,outs; int intm=0,outm=0; cin>>n; for(int i=0;i<n;i++){ cin>>s>>h1>>no>>m1>>no>>s1>>h2>>no>>m2>>no>>s2; t1=h1*3600+m1*60+s1; t2=h2*3600+m2*60+s2; if(i==0){ ins=s; outs=s; intm=t1; outm=t2; continue; } if(t1<intm){ intm=t1; ins=s; } if(t2>outm){ outm=t2; outs=s; } } cout<<ins<<" "<<outs<<endl; return 0;}
0 0
- PAT 1006. Sign In and Sign Out
- PAT 1006. Sign In and Sign Out
- 【PAT】1006. Sign In and Sign Out
- PAT-Sign In and Sign Out (25)
- 1006. Sign In and Sign Out (25)-PAT
- 【PAT】1006. Sign In and Sign Out (25)
- 【PAT Advanced Level】1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- 【PAT (Advanced Level)】1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- [PAT]1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- PAT A 1006. Sign In and Sign Out (25)
- PAT 1006. Sign In and Sign Out (25)
- pat 1006. Sign In and Sign Out (25)
- [PAT]1006. Sign In and Sign Out (25)
- AngularJS 的表单验证
- epoll相关介绍
- Quick-Cocos2d 资源与脚本
- 解线性方程组的直接方法(1):杜利特尔LU分解MATLAB实例
- mac终端命令
- [PAT]1006. Sign In and Sign Out (25)
- Backone初探——学生信息管理
- Java语言中的设计模式
- 发现被蹭网
- 控制别人的程序的按钮和编辑控件等
- Anaroid WebView详解
- camel Direct and import the routes from another XML file
- Android 打包Jar(发布SDK)常见问题及解决方案
- oc 之中的 汉字字符串转化成为拼音 汉字字符串的排序