172C
模拟
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<Set>
using namespace std;
struct pas
{
int x,t,num,time;
}p[];
set<int>s;
vector<int>stu[];
int n,m,time;
int pt[];
inline int min(int x,int y)
{
return x<y?x:y;
}
inline int max(int x,int y)
{
return x>y?x:y;
}
inline bool cp(pas x,pas y)
{
return x.t<y.t;
}
inline bool cp1(pas x,pas y)
{
return x.num<y.num;
}
int main()
{
cin>>n>>m;
for(int i=;i<=n;i++)
{
scanf("%d%d",&p[i].t,&p[i].x);
p[i].num=i;
}
sort(p+,p+n+,cp);
int pre=;
while(pre<=n)
{
s.clear();
int dis=;
for(int i=pre;i<min(pre+m,n+);i++)
{
s.insert(p[i].x);
stu[p[i].x].push_back(i);
}
if(time<p[min(pre+m-,n)].t)
time+=(p[min(pre+m-,n)].t-time);
int last=;
for(set<int>::iterator it=s.begin();it!=s.end();it++)
{
time+=(*it-last);
for(int i=;i<stu[*it].size();i++)
p[stu[*it][i]].time=time;
time+=(+(stu[*it].size()/));
stu[*it].clear();
last=*it;
}
time+=*s.rbegin();
pre=min(pre+m,n+);
}
sort(p+,p+n+,cp1);
for(int i=;i<=n;i++)
printf("%d ",p[i].time);
return ;
}
172C的更多相关文章
- Git self-learning
---恢复内容开始--- 使用后的总结 git config --global user.name "" #设置和查看用户名git config --global user.ema ...
- xman_2019_format(非栈上格式化字符串仅一次利用的爆破)
xman_2019_format(非栈上格式化字符串仅一次利用的爆破) 首先检查一下程序的保护机制 然后用IDA分析一下 存在后门 首先malloc了一片堆空间,读入数据 把刚刚读入的数据当作格式化字 ...
随机推荐
- string、math类、random随机数、datetime、异常保护
今天讲的知识点比较多,比较杂,以至于现在脑子里还有点乱,慢慢来吧... string (1)string.length; (获得你string字符串的长度) (2)a = a.Trim(); 重新赋值 ...
- [No00004A]为什么你看了很多书,却依然没有洞见
摘要: 前几天有人在知乎上问:今天就回答下很多人问了很久的这个问题,并且解释一下如何构建系统化的知识体系.我想很多人看到这个问题,期待的答案是一个书单,可是我要告诉你这并没有什么卵用.我想大部分人都经 ...
- git push时错误提示的解决办法 By default, updating the current branch in a non-bare repository error: is denied,
在使用git将客户端的修改push到服务器上的时候,出现无法push,提示和stackoverflow上的http://stackoverflow.com/questions/2816369/git- ...
- 第六课——UIDynamicAnimator
今天我们要学习UIDynamicAnimator 仿真物理学 . UIKit 力学(Dynamics) 和动态效果(Motion Effects) . 创建力学基本流程: 创建运动管理 创建运动行为( ...
- oracle数据库误操作把表删除了,怎样恢复
一:表的恢复 对误删的表,只要没有使用PURGE永久删除选项,那么从flash back区恢复回来希望是挺大的.一般步骤有:1.从flash back里查询被删除的表 select * from re ...
- 定时取数据库的schema,并推送到git服务器
写了个脚本,定时去数据库取schema,并推送到公司的git里. #daily_schema.py #/usr/bin/env python import os import datetime,tim ...
- centos 命令集合
链接: http://www.cnblogs.com/zitsing/archive/2012/05/02/2479009.html http://www.centoscn.com/CentOS/he ...
- linux查看出口ip 及w3m字符浏览器
Linux 查看服务器出口IP 字符浏览器: http://wiki.ubuntu.org.cn/W3m
- Vue系列:如何将百度地图包装成Vue的组件
主要分解为如下步骤: (1)在html文件中引入百度地图, <script type="text/javascript" src="http://api.map.b ...
- ASP.NET Web API Help Pages using Swagger
Understanding the various methods of an API can be a challenge for a developer when building a consu ...