Gym - 101158C Distribution Center
题意:n个传送带,传送带i运送编号为i的物品,机器人可以负责把传送带i上的物品放到传送带i + 1上,也可以把传送带i + 1上的物品放到传送带i上,机器人分布在传送带上x轴的不同位置,问每个传送带最多能传送多少物品。
分析:
1、将机器人按x轴排序。
2、对于每个传送带,记录它能传送的最小的传送带编号和能传送的最大的传送带编号即可。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
const double eps = 1e-12;
inline int dcmp(double a, double b)
{
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 200000 + 10;
const int MAXT = 3025 + 10;
using namespace std;
struct Node{
int x, id;
void read(){
scanf("%d%d", &x, &id);
}
bool operator < (const Node&rhs)const{
return x < rhs.x;
}
}num[MAXN];
int l[MAXN], r[MAXN];
int main(){
int n, m;
scanf("%d%d", &n, &m);
for(int i = 0; i < m; ++i){
num[i].read();
}
for(int i = 1; i <= n; ++i){
l[i] = i;
r[i] = i;
}
sort(num, num + m);
for(int i = 0; i < m; ++i){
int y = num[i].id;
l[y] = l[y + 1] = min(l[y], l[y + 1]);
r[y] = r[y + 1] = max(r[y], r[y + 1]);
}
for(int i = 1; i <= n; ++i){
if(i != 1) printf(" ");
printf("%d", r[i] - l[i] + 1);
}
printf("\n");
return 0;
}
Gym - 101158C Distribution Center的更多相关文章
- Gym 100801D Distribution in Metagonia (数学思维题)
题目:传送门.(需要下载PDF) 题意:t组数据,每组数据给定一个数ni(1 ≤ ni ≤ 10^18),把ni拆成尽可能多的数,要求每个数的素因子只包含2和3,且这些数不能被彼此整除,输出一共能拆成 ...
- 2293: Distribution Center 中南多校
Description The factory of the Impractically Complicated Products Corporation has many manufacturing ...
- Difference between the Bill of distribution and sourcing rule.
https://forums.oracle.com/thread/936768 This is from a users guide Oracle Supply Chain Planning ...
- linux查看端口及端口详解
今天现场查看了TCP端口的占用情况,如下图 红色部分是IP,现场那边问我是不是我的程序占用了tcp的链接,,我远程登陆现场查看了一下,这种类型的tcp链接占用了400多个,,后边查了一下资料,说E ...
- windows常用端口对应表
端口概念 在网络技术中,端口(Port)大致有两种意思:一是物理意义上的端口,比如,ADSL Modem.集线器.交换机.路由器用于连接其他网络设备的接口,如RJ-45端口.SC端口等等.二是逻辑意义 ...
- word20161213
journal queue / 日志队列 journal quota / 日志配额 junction point / 交叉点 KDC, Key Distribution Center / 密钥分发中心 ...
- Kerberos是怎么工作的?
Kerberos是一种计算机网络授权协议,用来在非安全网络中,对个人通信以安全的手段进行身份认证. 采用客户端/服务器结构,并且能够进行相互认证,即客户端和服务器端均可对对方进行身份认证. 关键要素 ...
- CAS实现SSO单点登录原理
1. CAS 简介 1.1. What is CAS ? CAS ( Central Authentication Service ) 是 Yale 大学发起的一个企业级的.开源的项目,旨 ...
- DNS错误 事件4000 4013
DNS 错误事件4000 4013,无法创建活动目录本身的区域 WINDOWS 2003 DNS服务器无法解析 错误ID 4000 DNS 服务器无法打开 Active Directory.这台 DN ...
随机推荐
- EC20指令
SIM卡热插拔检测: AT+QSIMSTAT=1 //开启SIM卡热拔插状态报告AT+QSIMDET=1,1或AT+QSIMDET=1,0//开启 SIM卡检测功能当SIM卡拔出或者 ...
- aws-ec2-upload
EC2上建立文件夹并开放权限 $ mkdir /home/upload$ chmod 777 /home/upload 本机文件 上传 到EC2服务器$ scp -i awsub01.pem noip ...
- 谈谈spring mvc与struts的区别
1.Struts2是类级别的拦截, 一个类对应一个request上下文,SpringMVC是方法级别的拦截,一个方法对应一个request上下文,而方法同时又跟一个url对应,所以说从架构本身上Spr ...
- Python 基础之返回值与函数使用与局部变量和全局变量locals() 和 globals()
一.函数的返回值 return return: 自定义返回值,返回到哪里? 返回到函数的[调用处]1.return 后面可以跟上六个标准数据类型,除此之外,可以跟上 类对象,函数,如果不写return ...
- 设计模式课程 设计模式精讲 18-2 迭代器模式coding
1 代码演练 1.1 代码演练1(迭代器模式演练) 1.2 代码使用场景 1 代码演练 1.1 代码演练1(迭代器模式演练) 需求: 课程管理:需要实现课程可进行增添,删除,并能够打印出课程列表. u ...
- SVN提交失败:Changing file 'XXX' is forbidden by the server;Access to 'XXX' forbidden
解决方案:https://blog.csdn.net/m0_38084243/article/details/81503638 个人分析主要是后者,在SVN服务器上添加上我对本项目的读写权限即可: 添 ...
- mabatisplus-update
/** * <p> * 根据 whereEntity 条件,更新记录 * </p> * * @param entity 实体对象 (set 条件值,不能为 null) * @p ...
- java并发初探CyclicBarrier
java并发初探CyclicBarrier CyclicBarrier的作用 CyclicBarrier,"循环屏障"的作用就是一系列的线程等待直至达到屏障的"瓶颈点&q ...
- Mac如何升级自带的vim
brew install vim --with-lua --with-override-system-vi brew install macvim --with-lua --with-override ...
- liunx命令用到的
su:切换成root用户 sudo su:普通用户申请root权限 ping命令可以检查linux是否联网 ping www.baidu.com 如图就是联网了 结束ping包括其他linux的指令 ...