https://codeforc.es/contest/1088/problem/B

模拟即可。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll; priority_queue<int, vector<int>, greater<int> >pq;
int sumsub = 0; int main() {
#ifdef Yinku
freopen("Yinku.in", "r", stdin);
//freopen("Yinku.out", "w", stdout);
#endif // Yinku
int n, k;
while(~scanf("%d%d", &n, &k)) {
while(!pq.empty())
pq.pop();
for(int i = 1; i <= n; i++) {
int tmp;
scanf("%d", &tmp);
pq.push(tmp);
}
sumsub = 0;
for(int i = 1; i <= k; i++) {
int tmp = 0;
while(!tmp) {
if(pq.empty())
break;
tmp = pq.top() - sumsub;
pq.pop();
}
printf("%d\n", tmp);
sumsub += tmp;
}
}
}

Codeforces - 1088B - Ehab and subtraction - 堆的更多相关文章

  1. Codeforces Round #525 (Div. 2)B. Ehab and subtraction

    B. Ehab and subtraction 题目链接:https://codeforc.es/contest/1088/problem/B 题意: 给出n个数,给出k次操作,然后每次操作把所有数减 ...

  2. 2018.12.05 codeforces 948C. Producing Snow(堆)

    传送门 维护一个堆. 每次先算出一个都不弹掉的总贡献. 然后把要弹掉的弹掉,并减去它们对应的贡献. 代码: #include<bits/stdc++.h> #define ri regis ...

  3. Codeforces 1088E Ehab and a component choosing problem

    Ehab and a component choosing problem 如果有多个连接件那么这几个连接件一定是一样大的, 所以我们先找到值最大的连通块这个肯定是分数的答案. dp[ i ]表示对于 ...

  4. 【题解】Berland.Taxi Codeforces 883L 模拟 线段树 堆

    Prelude 题目传送门:ヾ(•ω•`)o Solution 按照题意模拟即可. 维护一个优先队列,里面装的是正在运营中的出租车,关键字是乘客的下车时间. 维护一个线段树,第\(i\)个位置表示第\ ...

  5. Codeforces 854C Planning(贪心+堆)

    贪心:让代价大的尽量移到靠前的位置. 做法:先让前k个数加进堆里,枚举k+1~n+k,每次把新元素加进堆后找到最大代价放在当前位置即可. #include<bits/stdc++.h> # ...

  6. Codeforces 946 B.Weird Subtraction Process

    B. Weird Subtraction Process   time limit per test 1 second memory limit per test 256 megabytes inpu ...

  7. codeforces#1157D. Ehab and the Expected XOR Problem(构造)

    题目链接: http://codeforces.com/contest/1174/problem/D 题意: 构造一个序列,满足以下条件 他的所有子段的异或值不等于$x$ $1 \le a_i< ...

  8. Codeforces 1174C Ehab and a Special Coloring Problem

    题目链接:http://codeforces.com/problemset/problem/1174/C 题意:给你一个n,要你填充 下标由2 ~ n 的数组ai,要求下标互质的俩个数不能相等,并且数 ...

  9. Codeforces 1174B Ehab Is an Odd Person

    题目链接:http://codeforces.com/problemset/problem/1174/B 题意:给定长度 n 的数组,任意俩个相加为奇数的数可以交换数组中的位置,让这个数组尽量从小到大 ...

随机推荐

  1. select 项目<选课系统>

    """1. 创建北京.上海 2 所学校 学校类对象 属性:名字,地址 行为: 2. 创建linux , python , go 3个课程 , linux\py 在北京开, ...

  2. .NET File 多图上传

    HTML代码: <div> <div> <input type="file" style="display:none" id=&q ...

  3. VS2012 改C# 模版

    原始文件位置: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplatesCache\CSharp\Co ...

  4. Firewalld--01 防火墙安全、基本指令、区域配置

    目录 Firewalld防火墙安全.基本指令.区域配置 1. 防火墙安全基本概述 2. 防火墙使用区域管理 3. 防火墙基本指令参数 4.防火墙区域配置策略 Firewalld防火墙安全.基本指令.区 ...

  5. pwd 显示当前所在的工作路径

    1.功能说明 pwd命令是“print working directory ”首字母缩写,显示当前目录的绝对路径. 2.语法格式 pwd [option] pwd 选项 3.命令参数 参数 参数说明 ...

  6. git@github.com出现Permission denied (publickey)

    上传项目的时候出现Permission denied (publickey)这个问题 解决方案如下: 看本地的.git/config设置的仓库url地址和github使用的链接地址是否一致如下图,如u ...

  7. BZOJ 5046 分糖果游戏

    网页崩溃了 心态也崩溃了 MD劳资写了那么多 题意: 有a,b两个人分糖,每个人都有一个能量值.每个人每一轮可以选择进行两种操作: 1.取走最左边的糖果,补充相应的能量值并获取相应的美味度. 2.跳过 ...

  8. struts2的相关知识(实现原理、拦截器)

    struts2的实现原理 客户端初始化一个指向Servlet容器(例如Tomcat)的请求 这个请求经过一系列的过滤器(Filter)(这些过滤器中有一个叫做ActionContextCleanUp的 ...

  9. Flsak中的socket是基于werkzeug实现的。

    from werkzeug.serving import run_simple from werkzeug.wrappers import Request,Respinse @Request.appl ...

  10. AMROC可视化

    备注 通过修改Filetype来改变输出数据的类型. hdf2tab.sh转换全部数据文件 hdf2tab.sh -m多维数据 <!DOCTYPE html PUBLIC "-//W3 ...