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了一片堆空间,读入数据 把刚刚读入的数据当作格式化字 ...
随机推荐
- reflect2015破解
具体看 http://download.congci.com/download/net-reflector-7-6-1-824-wanquan-pojie#downloads *博主注:因为很多破解程 ...
- MYSQL数据库的操作
Mysql的连接方式: 1.原生函数:mysql_connect($server,$username,$password); //打开一个到Mysql服务器的连接 mysql_select_db( ...
- Android webview通过http get下载文件下载两次的问题及解决方法
一.现象 一般通过Android webview进行下载文件的方法是 1.重写DownloadListener的onDownloadStart方法,在onDownloadStart方法中弹出对话框提示 ...
- Activity 与 Service 之间的消息传递
BgService代码 public class BgService extends Service { public static final String TAG = "BgServic ...
- log4j.properties 详解与配置步骤(转)
找的文章,供参考使用 转自 log4j.properties 详解与配置步骤 一.log4j.properties 的使用详解 1.输出级别的种类 ERROR.WARN.INFO.DEBUGERROR ...
- Smoothing in fMRI analysis (FAQ)
Source: http://mindhive.mit.edu/node/112 1. What is smoothing? "Smoothing" is generally us ...
- BZOJ 2440 【中山市选2011】 完全平方数
Description 小 X 自幼就很喜欢数.但奇怪的是,他十分讨厌完全平方数.他觉得这些数看起来很令人难受.由此,他也讨厌所有是完全平方数的正整数倍的数.然而这丝毫不影响他对其他数的热爱. 这天是 ...
- KeyBord事件从Activtiy层往下分发详细过程代码示例
step1:调用Activity成员函数dispatchKeyEvent public boolean dispatchKeyEvent(KeyEvent event) { // Let action ...
- Cannot resolve external dependency com.android.support:multidex:1.0.0
multiDexEnabled true 去掉这一行,就OK了,是没有多dex支持么,但是又提供了这个
- sobel算子
#1,个人理解 网上查了很多资料,都说sobel算子是用来检测边缘的,分别给了两个方向上的卷积核,然后说明做法,就说这就是sobel算子.对于我个人来说,还有很多不明白的地方,所以理清下思路. #2, ...