一个离散化的简单题;

我用的是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. oracle6

    转换函数  介绍 转换函数用于将数据类型从一种转为另外一种.在某些情况下,oracle server允许值的数据类型和实际的不一样,这时oracle server会隐含的转化数据类型 比如: crea ...

  2. Windows与Linux下文件操作监控的实现

    一.需求分析: 随着渲染业务的不断进行,数据传输渐渐成为影响业务时间最大的因素.究其原因就是因为数据传输耗费较长的时间.于是,依托于渲染业务的网盘开发逐渐成为迫切需要解决的需求.该网盘的实现和当前市场 ...

  3. Winform中修改WebBrowser控件User-Agent的方法(已经测试成功)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.W ...

  4. Setup Tensorflow with GPU on Mac OSX 10.11

    Setup Tensorflow with GPU on OSX 10.11 环境描述 电脑:MacBook Pro 15.6 CPU: 2.7GHz 显卡: GT 650m 系统:OSX 10.11 ...

  5. RedHat7搭建MongoDB集群

    下载RPM安装包# wget -c -r -N -np -nd -L -nH https://repo.mongodb.org/yum/redhat/7/mongodb-org/stable/x86_ ...

  6. C#百分比式布局

    图一:原始窗口 图二:放大窗口 实现:窗体内添加一个panel1(Dock:Left),在窗体空余部分添加第二个panel2(Dock:Fill),窗体分为两部分. 在panel2内添加一个panel ...

  7. 锱铢必较,从(function(){}())与(function(){})()说起

    今天做JsHint时,碰到一个警告:应该使用(function(){}())而不是(function(){})();看到这个我心想,这两种函数自执行有什么区别吗?自执行用了这么久,感觉对其理解仍然有点 ...

  8. Access获取新插入数据的自增长主键Id

    sqlserver有output,Oracle有Sequence.Access用下面的方法: public int InsertEx(User user) { ; using (OleDbConnec ...

  9. phpmyadmin备份小问题

    不要将imformation——shame或者mysql等备份,要有选择的备份表 关注我的新浪微博

  10. Sublime Text 3配置LiveReload实现实时刷新

    今天看到一款很强大的插件,LiveReload,实时刷新,也就是说写完html/css/js等不用再到浏览器里按F5啦,在Ctrl+S时浏览器会自动刷新,是不是想想都很爽... Chrome:(据说支 ...