Aizu The Maximum Number of Customers
2024-09-04 13:25:55
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
最新文章
- npapi插件开发流程与实例
- Oracle Database 11g Release 2(11.2.0.3.0) RAC On Redhat Linux 5.8 Using Vmware Workstation 9.0
- Unsupported major.minor version 52.0
- oracle计算两行差值
- svg是什么
- Web前端开发规范文档
- 部署报表和 ReportViewer 控件 rdlc
- leetcode single number系列
- ASP.ENT Core Linux 下 为 donet创建守护进程(转载)
- 总结iframe高度自适应,自适应子页面高度
- windows查询端口
- request.getParameter() 和request.getAttribute() 区别
- 获取某个元素第一次出现在数组(json数组)的索引
- python基础系列教程,数学基础系列教程,数据分析系列教程,神经网络系列教程,深度学习系列视频教程分享交流
- html图片上传阅览并且点击放大
- Linux 定时任务 crontab 和 Systemd Timer
- c++11并发之std::thread
- puppet应用案例
- [转载]WeeksInAYear、WeeksInYear、DaysInAYear、DaysInAMonth、DaysInYear、DaysInMonth - 获取指定年月的周、日数
- i春秋CTF web题(1)
热门文章
- poj3349找相同的雪花(哈希)
- MVC中Cookies的简单读写操作
- SyntaxError: (unicode error) &#39;unicodeescape&#39; codec can&#39;t decode bytes in position 2-3: truncated \UXXXXXXXX escape错误原因及解决方法
- kubernetes命令补全
- idea进行断点快捷键
- Linux配置SSH免密码登录
- tcp 粘包 和 TCP_NODELAY 学习
- Django-5.2 模型层 多表操作
- IntelliJ IDEA里找不到javax.servlet的jar包
- Mongodb installation &; userguide