German Collegiate Programming Contest 2013:B
一个离散化的简单题;
我用的是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的更多相关文章
- German Collegiate Programming Contest 2013:E
数值计算: 这种积分的计算方法很好,学习一下! 代码: #include <iostream> #include <cmath> using namespace std; ; ...
- 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 ...
- 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 ...
- 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. ...
- 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: ...
- 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, ...
- 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 ...
- 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 ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem C
Problem C Character Recognition? Write a program that recognizes characters. Don't worry, because yo ...
随机推荐
- 经验总结17--submitbutton,ajax提交
发篇小文章,纪念七七事变. submit一般用于提交表单,可是想使用ajax进行提交,又想按"enter"触发button. 那么就阻止提交表单的事件,进行自己定义的提交. 1.让 ...
- mybatis0202 一对一查询 resultType实现
一对一查询 查询订单信息和用户信息 创建po类 基础的单表的 po(数据库类)类:Items.java, Orderdetail.java, Orders.java, User.java 一对一查询映 ...
- /dev/tty 与 /dev/pts
打开3个bash会话窗口 [root@server1 fd]# cd /proc/7489/fd[root@server1 fd]# ll总用量 0lrwx------ 1 root root 6 ...
- 【Android】数据库的简单应用——创建数据库
SQLiteOpenHelper是一个抽象类,要使用它必须写一个类继承它.SQLiteOpenHelper有两个抽象方法onCreate()和onUpgrade(),我们要在类里面重写这两个方法来实现 ...
- .net+easyui系列--验证框
1.允许从 0 到 10个字符 <input id="vv" class="easyui-validatebox" data-options=" ...
- PHP中的strtotime()对于31日求上个月有问题
原文出处 <?php $date = "2012-07-31"; $date_unix = strtotime($date); $lastmonth = strtotime( ...
- Spring读书笔记-----Spring的Bean之设置Bean值
[java] view plaincopyprint? Java实例的属性值可以有很多种数据类型.基本类型值.字符串类型.java实例甚至其他的Bean实例.java集合.数组等.所以Spring允许 ...
- C# 反射之属性操作
一.反射-类操作 //1.获取对象所有的属性名 Student stu = new Student(); //获取当前类名称 Console.WriteLine(stu.GetType().Name) ...
- 1.RABBITMQ 入门 - WINDOWS - 获取,安装,配置
一. 背景: 公司项目有所改动,要求微信(移动端调用的接口),日志接口换位log4net,全部改成以rabbitMQ作为服务支持, 二.本地环境: windows 10 enterpr ...
- sql sever怎样替换把表中数据。
怎样替换把表中“舞台桁架厂”替换为“舞台桁架厂家” 表数据结构为: id name key addre ...