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 说明:最大线 ...
随机推荐
- Codeforces 316C2 棋盘模型
Let's move from initial matrix to the bipartite graph. The matrix elements (i, j) for which i + j ar ...
- Android MVP模式实现组件和业务逻辑分离
1,Activity代码展示,只需要一下3行重要代码即可完成任何复杂的逻辑 /** * 登录界面 * * @author lipanquan */public class LoginActivity ...
- Go语言基础之7--函数详解
一. 函数介绍 1.1 定义 函数:有输入.有输出,用来执行一个指定任务的代码块. func functionname([parametername type]) [return type] { // ...
- Linux网络编程基础
1. Linux网络模型 ① OSI七层模型和Linux四层模型 ② 各种协议之间的关系及在Linux模型中的位置 ③ 协议封装:各种协议处于一种层层封装的关系 (1)Ethernet (2)IP * ...
- Eclipse + Git + 码云
1. 进入码云个人首页 点击自己的名称即可 2. 添加一个项目 3. 在Eclipse中创建一个本地Git Eclipse不建议git目录创建在项目的目录下,因此另选一个目录作为本地Git目录 选择一 ...
- py---------面向对象进阶
一.isinstance 和 issubclass isinstance(obj,cls)检查obj是否是类cls的对象,是则返回True class Foo(object): pass obj = ...
- 爬虫(GET)——爬取多页的html
工具:python3 目标:将编写的代码封装,不同函数完成不同功能,爬取任意页数的html 新学语法:with open as 除了有更优雅的语法,with还可以很好的处理上下文环境产生的异常. # ...
- SQL Server Reporting Service(SSRS) 第五篇 自定义数据处理扩展DPE(Data Processing Extension)
最近在做SSRS项目时,遇到这么一个情形:该项目有多个数据库,每个数据库都在不同的服务器,但每个数据库所拥有的数据库对象(table/view/SPs/functions)都是一模一样的,后来结合网络 ...
- Unity 平台宏定义
官方文档: https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
- C# 反射 Type.GetFields 方法
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Reflecti ...