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的更多相关文章

  1. 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 ...

  2. 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.免费应用程序调试最 ...

  3. [LeetCode] Third Maximum Number 第三大的数

    Given a non-empty array of integers, return the third maximum number in this array. If it does not e ...

  4. [LeetCode] Create Maximum Number 创建最大数

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...

  5. LeetCode 414 Third Maximum Number

    Problem: Given a non-empty array of integers, return the third maximum number in this array. If it d ...

  6. Failed to connect to database. Maximum number of conections to instance exceeded

    我们大体都知道ArcSDE的连接数有 48 的限制,很多人也知道这个参数可以修改,并且每种操作系统能支持的最大连接数是不同的. 如果应用报错:超出系统最大连接数 该如何处理? 两种解决办法: 第一,首 ...

  7. POJ2699 The Maximum Number of Strong Kings

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2102   Accepted: 975 Description A tour ...

  8. [LintCode] Create Maximum Number 创建最大数

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...

  9. 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 说明:最大线 ...

随机推荐

  1. 经典SQL行列转换

    -- http://www.programbbs.com/doc/4885.htm /* 标题:普通行列转换(version 2.0) 说明:普通行列转换(version 1.0)仅针对sql ser ...

  2. ButterKnife 8.4注入失败

    1,第一步:项目的gradle中增加 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'buildscript { repositor ...

  3. 签名:实现参数字典排序,然后拼接为url参数形式

    在很多地方请求参数需要做处理例如: 步骤 1.参数字典排序. 2.拼接字符. /// <summary> /// 生成签名 /// </summary> /// <par ...

  4. apache 与php的安装

    1 系统环境与软件   1 php5.5.6 下载链接:http://windows.php.net/download/#php-5.5 推荐 V11 x64,也就是64bit的. 2 apache2 ...

  5. battery-historian结果分析

    准备电量数据: 1. 断开adb服务 执行:adb kill-server 2. 开启adb服务 执行:adb start-server或者adb devices这两步操作的作用:adb作为一种连接的 ...

  6. execlp启动android进程命令

    execlp启动Android界面或service/广播参数设置 -n代表打开组件-d代表 data-a代表action 打开网页 调用am命令 if (sdkVersion >= 17) { ...

  7. (转)shell解析命令行的过程以及eval命令

    shell解析命令行的过程以及eval命令   本文说明的是一条linux命令在执行时大致要经过哪些过程?以及这些过程的大致顺序. 1.1 shell解析命令行 shell读取和执行命令时的大致操作过 ...

  8. Python3实现计算BMI指数,跟我一起来计算你的BMI吧

    废话不多说,直接上程序哈: name=input('Name:') height=input('Height(m):') weight=input('Weight(kg):') BMI=float(f ...

  9. SUN巡检命令

    # hostname (主机名)# hostid# uname -X# uname -a # w (进程)# who# last# ps -eaf# /usr/ucb/ps -aux# prstat ...

  10. 查看服务器配置信息prtdiag与systeminfo实用命令

    UNIX(SUN服务器)bash-2.05# prtdiag -v系统配置:  Sun Microsystems  sun4u Sun Fire V890系统时钟频率:150 MHz内存大小:3276 ...