CodeForces 644B【模拟】
题意:
查询数 和 最大的队列容量+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【模拟】的更多相关文章
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- CodeForces - 404B(模拟题)
Marathon Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- Codeforces 709B 模拟
B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- CodeForces - 404A(模拟题)
Valera and X Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- Codeforces 390A( 模拟题)
Inna and Alarm Clock Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64 ...
- Codeforces 452D [模拟][贪心]
题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的 ...
- CodeForces - 796B 模拟
思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include ...
- CodeForces - 864C-Bus-(模拟加油站问题)
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...
- Codeforces 709C 模拟
C. Letters Cyclic Shift time limit per test:1 second memory limit per test:256 megabytes input:stand ...
随机推荐
- duplicate symbols for architeture arm64 linker command failed with code 1(use-c to see invocation)
duplicate symbols for architeture arm64 linker command failed with code 1(use-c to see invocation) ...
- js中变量的声明
大家都知道js中变量的声明是要提前的,下面有4个样例: 1.if(!"t" in window){ var t = 1; } alert(t);答案是undefine ...
- 【BZOJ1520】[POI2006]Szk-Schools KM算法
[BZOJ1520][POI2006]Szk-Schools Description Input Output 如果有可行解, 输出最小代价,否则输出NIE. Sample Input 5 1 1 2 ...
- java关于数组之间的相互赋值
java中数组是被当作对象看待,假设a,b为两个已经初始化的数组,那么语句a=b就表示把b数组对象的引用赋值给a,那么a和b就指向了同一个数组,无论用哪个来操作都影响其指向的数组.原来a指向的数组现在 ...
- Page (computer memory)
A page, memory page, or virtual page is a fixed-length contiguous block of virtual memory, described ...
- 在Win7创建WiFi热点
1.在开始菜单搜索cmd 2.运行cmd 3.输入以下命令,注意:Your-WiFi-Name和Your-WiFi-Password分别为WiFi名称和密码 netsh wlan set hosted ...
- 阻止SSIS import excel时的默认行为
为什么SSIS总是错误地获取Excel数据类型,以及如何解决它! 由Concentra发布 2013年5月15日 分享此页面 分享 发现Concentra的分析解决方案 Concentra的分析和 ...
- linux内核container_of宏定义分析
看见一个哥们分析container_of很好,转来留给自己看 一.#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMB ...
- Ubuntu下codeblocks编译器程序执行对话框内能进行粘贴编辑操作的指令
如这个: gnome-terminal -t $TITLE -x
- C++打印变量地址
%p专门用来打印变量的以十六进制表示的地址: #include<iostream> using namespace std; int main() { ; printf("a的地 ...