题意:

查询数 和 最大的队列容量+1;

按时间顺序

ti代表,第i个出线的时间;

di代表,第i个需要处理的时间;

对于第i个输出他所需要的时间完成,或者拒绝进入输出-1;

思路:

真是MDZZ了,模拟。

主要就是开个队列存了一下每个任务结束时间,然后对于每个任务把队列里小于该任务开始时间pop掉,队列里的个数就可以代表当前处理个数了

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
typedef pair<int,int>P;
queue<int>q;
LL ans[N];
int main()
{
int n,b;
LL x,y,now,num;
scanf("%d%d",&n,&b);
b++;
scanf("%lld%lld",&x,&y);
ans[1]=x+y;
now=x+y;
q.push(now);
for(int i=2;i<=n;i++)
{
scanf("%d%d",&x,&y);
while(!q.empty())
{
int u=q.front();
if(u<=x)
q.pop();
else
break;
}
if(x>=now)
{
now=x+y;
q.push(now);
ans[i]=x+y;
}
else
{
if(q.size()+1<=b)
{
ans[i]=now+y;
now=now+y;
q.push(now);
}
else
ans[i]=-1;
}
}
for(int i=1;i<=n;i++)
printf("%lld ",ans[i]);
return 0;
}

CodeForces 644B【模拟】的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 709B 模拟

    B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...

  4. CodeForces - 404A(模拟题)

    Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit ...

  5. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  6. Codeforces 452D [模拟][贪心]

    题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...

  7. CodeForces - 796B 模拟

    思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...

  8. CodeForces - 864C-Bus-(模拟加油站问题)

    https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...

  9. Codeforces 709C 模拟

    C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...

随机推荐

  1. RYU改动监听port Mininet在custom自建拓扑和连接到指定控制器命令解释

    1.RYU控制器改动监听port 在ryu/ryu/ofproto以下的ofproto_common.py watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc ...

  2. EasyRTMP实现RTMP异步直播推送之环形缓冲区设计

    本文转自EasyDarwin团队kim的博客:http://blog.csdn.net/jinlong0603 EasyRTMP的推送缓冲区设计 EasyRTMP内部也同样采用的环形缓冲的设计方法,将 ...

  3. 九度OJ 1084:整数拆分 (递归)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2274 解决:914 题目描述: 一个整数总可以拆分为2的幂的和,例如: 7=1+2+4 7=1+2+2+2 7=1+1+1+4 7=1+1 ...

  4. GitLab Pages expect to run on their own virtual host

    GitLab Pages administration | GitLab https://docs.gitlab.com/ce/administration/pages/

  5. Activity和ListActivity的区别

    http://book.51cto.com/art/201007/212051.htm

  6. 牛客练习赛14 D 比较月亮大小 【水】

    链接:https://www.nowcoder.com/acm/contest/82/D 来源:牛客网 比较月亮大小 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其 ...

  7. vuejs实现折叠面板展开收缩动画

    vuejs通过css3实现元素固定高度到auto高度的动画和auto高度到固定高度的动画. 循环列表,html: <template> <div class="newsli ...

  8. CSU - 1550 Simple String —— 字符串

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1550 题解: 1.A+B 与C的交集必须>=n 2.A与C的交集必须>= ...

  9. 关于redis的思考

    集群版本的redis主从复制 也可以实现集群 但是不是很好 集群版redis主从复制版本集群 Spring Boot整合Redi事务 Spring Boot+Redis+Ehcache实现二级缓存 S ...

  10. oracle查看锁表进程,杀掉锁表进程

    查看锁表进程SQL语句1: select sess.sid,     sess.serial#,     lo.oracle_username,     lo.os_user_name,     ao ...