一个离散化的简单题;

我用的是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. android 75 新闻列表页面

    new.xml <?xml version="1.0" encoding="UTF-8" ?> <newslist> <news& ...

  2. hadoop错误Cannot load libsnappy.so.1 (libsnappy.so.1 cannot open shared object file No such file or directory)!

    报如下错误 解决方法: 1.下载libsnappy.so.1(https://yunpan.cn/cSHRHTBJGVVX6  访问密码 c992) 2.上传到linux系统 3.安装 4.安装完成后 ...

  3. android开发之bitmap使用

    bitmap是android中重要的图像处理工具类,通过bitmap可以对图像进行剪切.旋转.缩放等操作,同时还可以指定格式和压缩质量保存图像文件. 一.拿到一个Bitmap对象 查看源码我们知道,B ...

  4. javascript中的call()和apply应用

    在javascript开发过程中,如果有看过几个javascirpt代码库,就会发现经常使用到call()和apply()函数,call()和aplly()结合javascript允许传递函数名,这种 ...

  5. codeforces 132C Logo Turtle(dp)

    可以用三维dp来保存状态, dp[i][j][k]表示在前i个字符变换了j步之后方向为k(k = 1 or k = 0)的最优解,也就是离原点的最大距离.这里规定0方向为正方向,1位负方向,表示的是当 ...

  6. readonly时禁用删除键,readonly按删除键后页面后退解决方案

    readonly时禁用删除键, readonly按删除键后页面后退解决方案 >>>>>>>>>>>>>>>&g ...

  7. 版本控制SVN与Eclipse4.4.1集成 ( eclipse svn:E175002错误解决 )

    Eclipse版本--Luna Service Release 1(4.4.1) SVN版本-----1.8.X 系统OS-------ubuntu 14.04 LTS 1.通过地址安装 Help-& ...

  8. MES项目中出现的一个事务嵌套的使用场景

    昨天在MES项目中,需要在业务逻辑的几个关键点记录错误信息,需要把错误信息写入数据表. 但是由于整个业务逻辑都是包在一个事务模板里面的 比如这样的: WhhTransactionTemplate tr ...

  9. CSS Margin(外边距)

    CSS Margin(外边距)属性定义元素周围的空间. Margin margin清除周围的元素(外边框)的区域.margin没有背景颜色,是完全透明的 margin可以单独改变元素的上,下,左,右边 ...

  10. CSS 边框

    CSS 边框属性 CSS边框属性允许你指定一个元素边框的样式和颜色. 边框样式 边框样式属性指定要显示什么样的边界.  border-style属性用来定义边框的样式 border-style 值: ...