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 ...
随机推荐
- 一堂C++课玩转rpm包的制作
常见的Linux发行版主要可以分为两类,类ReadHat系列和类Debian系列,这里我们是以其软件包的格式来划分的,这两类系统分别提供了自己的软件包管理系统和相应的工具.类RedHat系统中软件包的 ...
- 在与SQL Server 建立 连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器
- Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Error: Package: mysql-community-server-8.0.12-1.el7.x86_64 (mysql80-community) Requires: libstdc++.s ...
- sort_action
li, r = [23,8, 45, 5, 0, -6, 745,8, 8], [] while (len(li) > 0): loop_, min, tag = len(li), li[0], ...
- Git配置的用户名密码在本地的存贮位置
全局的用户名密码配置: //配置用户名和邮箱(全局) $ git config --global user.name "j***n" $ git config --global u ...
- Oracle Meger into 函数
Oracle 在 9i 引入了 merge 命令, 通过这个 merge 能够在一个SQL 语句中对一个表同时执行 inserts 和 updates 操作.Merge into 可以实现用 B 表来 ...
- CSU1808 地铁 —— dijkstra变形
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1808 题解:由于中转线路需要花费一定的时间,所以一般的以顶点为研究对象的dijkst ...
- mac配置apache
http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html 用自带的 sudo apachectl -v sudo apachectl ...
- x264 --fullhelp
>x264 --fullhelp x264 core: Syntax: x264 [options] -o outfile infile Infile can be raw (in which ...
- hdu 1047 Integer Inquiry(大数)
题意:整数大数加法 思路:大数模板 #include<iostream> #include<stdio.h> #include<stdlib.h> #include ...