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 说明:最大线 ...
随机推荐
- 75th LeetCode Weekly Contest Champagne Tower
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so ...
- 剧本--ansible
剧本不喜欢, 1.1 编写剧本规范:(PYyaml语法格式文件) 剧本中有层级划分 每个层级都要用两个空格进行区分 第一级标题 第二级标题 第三级标题 强调注意:一定使用ansible软件配置剧本时, ...
- Spring Boot学习资料汇总
1. SpringFramework 重点学习 IOC容器,Web MVC framework,AOP 等 官网文档 http://docs.spring.io/spring/docs/cur ...
- C语言指针收藏
指针是什么 >>每一个内存单元只能同时存储一个数据,如何保证内存单元同时只能存储一个数据,可以使用编号的方式实现内存单元标记,此编号就是指针. >>指针是一个变量,指针是存放着 ...
- C#中Internal关键字的总结
https://blog.csdn.net/baidu_32134295/article/details/51285603 版权声明:本文为博主原创文章,未经博主允许不得转载. https:/ ...
- Linux ps命令记录
ps命令:查看当前系统进程状态 ps -a 显示当前所有进程ps -ax 显示没有控制终端的进程ps -u better 查看用户better的进程ps aux|less 通过cpu和内存来 ...
- Vue 中怎么发起请求(一)
1.vue 支持开发者引入 jquery 使用 $.ajax() 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1.首先,在 package.json 中添加 j ...
- 动态资源不缓存 filter
package com.itheima.web.filter; import java.io.IOException; import javax.servlet.Filter; import java ...
- C++ 虚函数、纯虚函数、虚继承
1)C++利用虚函数来实现多态. 程序执行时的多态性通过虚函数体现,实现运行时多态性的机制称爲动态绑定:与编译时的多态性(通过函数重载.运算符重载体现,称爲静态绑定)相对应. 在成员函数的声明前加上v ...
- jeecg3.8popup弹出窗口触发失去焦点事件,引发验证弹窗,影响体验问题的解决办法
在初始化表单的代码中添加以下加粗部分,有几个popup就定义几个标志位,主要是防止第一次失去焦点时候的弹窗(此时还未来得及选择),提交表单的时候还是会正常校验的. //popup触发失去焦点事件,设置 ...