一个离散化的简单题;

我用的是STL来做的离散化;

好久没写离散化了,纪念一下!

代码:

 #include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define maxn 5005
using namespace std;
vector<int>ve;
int mmb[]={,,,,,
,,,,,,};
struct node
{
int st,end;
}no[maxn]; char s[];
int lisan[maxn*]; int main()
{
int t,year,month,day,hour,min,m,n,mi;
scanf("%d",&t);
while(t--)
{
ve.clear();
scanf("%d%d",&n,&m);
for(int i=; i<n; i++)
{
scanf("%s",&s);
scanf("%d-%d-%d",&year,&month,&day);
scanf("%d:%d",&hour,&mi);
if(year==&&month>)
no[i].st=(year-)*+mmb[month-]+(day-)*+hour*+mi+;
else no[i].st=(year-)*+mmb[month-]+(day-)*+hour*+mi;
ve.push_back(no[i].st);
scanf("%d-%d-%d",&year,&month,&day);
scanf("%d:%d",&hour,&mi);
if(year==&&month>)
no[i].end=(year-)*+mmb[month-]+(day-)*+hour*+mi+m+;
else no[i].end=(year-)*+mmb[month-]+(day-)*+hour*+mi+m;
if(no[i].end==no[i].st)
ve.push_back(no[i].end+);
else ve.push_back(no[i].end);
}
sort(ve.begin(),ve.end());
ve.erase(unique(ve.begin(),ve.end()),ve.end());
memset(lisan,,sizeof lisan);
for(int i=; i<n; i++)
{
int pos=lower_bound(ve.begin(), ve.end(),no[i].st)-ve.begin();
lisan[pos]+=;
pos=lower_bound(ve.begin(), ve.end(),no[i].end)-ve.begin();
lisan[pos]+=-;
}
int mii=;
for(int i=; i<ve.size(); i++)
if(i>)
lisan[i]+=lisan[i-];
for(int i=; i<ve.size(); i++)
if(lisan[i]>mii)mii=lisan[i];
printf("%d\n",mii);
}
return ;
}

German Collegiate Programming Contest 2013:B的更多相关文章

  1. German Collegiate Programming Contest 2013:E

    数值计算: 这种积分的计算方法很好,学习一下! 代码: #include <iostream> #include <cmath> using namespace std; ; ...

  2. The Ninth Hunan Collegiate Programming Contest (2013) Problem A

    Problem A Almost Palindrome Given a line of text, find the longest almost-palindrome substring. A st ...

  3. The Ninth Hunan Collegiate Programming Contest (2013) Problem F

    Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roa ...

  4. The Ninth Hunan Collegiate Programming Contest (2013) Problem H

    Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. ...

  5. The Ninth Hunan Collegiate Programming Contest (2013) Problem I

    Problem I Interesting Calculator There is an interesting calculator. It has 3 rows of button. Row 1: ...

  6. The Ninth Hunan Collegiate Programming Contest (2013) Problem J

    Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...

  7. The Ninth Hunan Collegiate Programming Contest (2013) Problem G

    Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...

  8. The Ninth Hunan Collegiate Programming Contest (2013) Problem L

    Problem L Last Blood In many programming contests, special prizes are given to teams who solved a pa ...

  9. The Ninth Hunan Collegiate Programming Contest (2013) Problem C

    Problem C Character Recognition? Write a program that recognizes characters. Don't worry, because yo ...

随机推荐

  1. BZOJ 3265 志愿者招募增强版 单

    标题效果:同1061 只是间隔为每种类型的志愿工作是多级 这是卡网络流量?未知 所有在所有的1061您将可以更改为在稍微改变- - #include <cmath> #include &l ...

  2. Linux多网卡多IP配置

    echo "210 local100" >> /etc/iproute2/rt_tables echo "220 local200" >> ...

  3. app抓包

    http://www.360doc.com/content/14/1126/11/9200790_428168701.shtml 记得下载证书  不然有些网站是抓不到的

  4. 解决如下json格式的字符串不能使用DataContractJsonSerializer序列化和反序列化 分类: JSON 2015-01-28 14:26 72人阅读 评论(0) 收藏

    可以解决如下json格式的字符串不能使用DataContractJsonSerializer反序列化 {     "ss": "sss",     " ...

  5. 浅谈Mamcached集成web项目

    1.资源文件配置 config.properties 添加 #memcached服务器地址 memchchedIP=192.168.1.8 2.编写工具类 MemUtils package cn.co ...

  6. linq 中的分组查询

    直接看代码: //一个字段分组 var data1 = from a in query group a by a.Name into b select new { Total = b.Sum(c=&g ...

  7. c语言学习之基础知识点介绍(七):循环结构

    本节主要介绍循环结构 一.while循环 /* 语法: while(表达式){ //循环体; } 注意:循环变量.循环条件和循环控制语句三者缺一不可. 例如: */ ; //循环变量 ){ //循环条 ...

  8. Struts2中EL表达式取值

    http://blog.csdn.net/cuihaiyang/article/details/41950141 (写的不错,可以知道为什么struts2可以用El取属性值的问题.正常el从reque ...

  9. Eclipse快捷键,前几个很实用

    F3 :查看实现 F4(或control + T) :继承树 control + F6 :切换文件 control + F7 :切换视图 control + F8 :切换模板 control + O ...

  10. 2014-11-9------- 设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。

    一.            设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表( ...