Aizu The Maximum Number of Customers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_5_A The Maximum Number of Customers
Idea: find the most overlapped segment. Similiar to the line painting

Mark the left and right element, x: L, O: R
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
//https://www.hustyx.com/cpp/5/ -- reference
#define N 100005
int a[N];
int main(){
//input
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
memset(a,,N);
int n,t,l,r;
scanf("%d %d",&n,&t);
for(int i = ; i<n; i++){
scanf("%d %d",&l,&r);
a[l]++;
a[r]--;
}
//preprocess in the array
int max = ;
int count = ;
for(int i = ; i<N; i++){
count += a[i];
if(max<count) max = count;
}
printf("%d\n",max);
//printf("wei");
return ;
}
C++ learning from this code
* redefine the stream from input file
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
* memset in cstring
Aizu The Maximum Number of Customers的更多相关文章
- Maximum number of WAL files in the pg_xlog directory (1)
Guillaume Lelarge: Hi, As part of our monitoring work for our customers, we stumbled upon an issue ...
- iOS---The maximum number of apps for free development profiles has been reached.
真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...
- [LeetCode] Third Maximum Number 第三大的数
Given a non-empty array of integers, return the third maximum number in this array. If it does not e ...
- [LeetCode] Create Maximum Number 创建最大数
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...
- LeetCode 414 Third Maximum Number
Problem: Given a non-empty array of integers, return the third maximum number in this array. If it d ...
- Failed to connect to database. Maximum number of conections to instance exceeded
我们大体都知道ArcSDE的连接数有 48 的限制,很多人也知道这个参数可以修改,并且每种操作系统能支持的最大连接数是不同的. 如果应用报错:超出系统最大连接数 该如何处理? 两种解决办法: 第一,首 ...
- POJ2699 The Maximum Number of Strong Kings
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2102 Accepted: 975 Description A tour ...
- [LintCode] Create Maximum Number 创建最大数
Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...
- tomcat 大并发报错 Maximum number of threads (200) created for connector with address null and port 8080
1.INFO: Maximum number of threads (200) created for connector with address null and port 8091 说明:最大线 ...
随机推荐
- OJ 26217 :Work Scheduling(贪心+优先队列)
约翰有太多的工作要做.为了让农场高效运转,他必须靠他的工作赚钱,每项工作花一个单位时间. 他的工作日从0时刻开始,有10^8个单位时间.在任一时刻,他都可以选择编号1~N的N(1 <= N &l ...
- 2016"百度之星" - 资格赛(Astar Round1)D
Problem Description 度熊所居住的 D 国,是一个完全尊重人权的国度.以至于这个国家的所有人命名自己的名字都非常奇怪.一个人的名字由若干个字符组成,同样的,这些字符的全排列的结果中的 ...
- linux中的目录配置
一.权限对文件的重要性 1.r(read):可读取此文件的实际内容,读取文本文件的文字内容等. 2.w(write):可以编辑,新增或者是修改该文件的内容. 3.x(execute):该文件具有可以被 ...
- mybatis主键是在insert前生成还是之后生成
oracle sequence 推荐每个表使用自己的sequence mysql 使用每个表的autoincreate来当主键 mybatis 操作insert时 主键的生成是在插入之前 还是之后? ...
- SpringMVC DeferedResult和servlet3.1 AsyncContext异步请求
先看一个简单的示例: @RequestMapping("/getFuture") public Future<String> getFuture() { System. ...
- python dataframe drop_duplicates用法技巧去重
data.drop_duplicates()#data中一行元素全部相同时才去除 data.drop_duplicates(['a','b'])#data根据’a','b'组合列删除重复项,默认保留第 ...
- RTT之shell
两种shell的切换:如果打开了FINSH_USING_MSH而没有打开FINSH_USING_MSH_ONLY,finsh同时支持两种c-style模式与msh模式,但是默认进入c-style模式, ...
- Murano Weekly Meeting 2016.07.26
Meeting time: 2016.July.26 1:00~2:00 Chairperson: Nikolay_St, from Mirantis Meeting summary: 1.Masc ...
- ajax多次请求的一个效果思路
首先页面加载时候显示遮罩层 jQuery(function() { show_dialog(); //tianxie(); }); 定义一个全局数组,用于存放问题id var qar = []; 循环 ...
- Java中的阻塞队列-SynchronousQueue
SynchronousQueue是一个不存储元素的阻塞队列.每一个put操作必须等待一个take操作,否则不能继续添加元素.SynchronousQueue可以看成是一个传球手,负责把生产者线程处理的 ...