A:二分答案 如果中位数比目前的大就right=mid-1 else left=mid+1

C!:几何

G:优先队列贪心

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, int> pii;
int n, k, a[];
int main() {
scanf("%d%d", &n, &k);
for(int i = ; i <= n; i++) {
scanf("%d", &a[i]);
}
k--;
sort(a + , a + + n);
priority_queue<pii, vector<pii>, greater<pii> > pq;
pq.push(make_pair((LL)a[], ));
while(k--) {
pii top = pq.top();
pq.pop();
if(top.second == n) continue;
pq.push(make_pair(top.first - a[top.second] + a[top.second + ], top.second + ));
pq.push(make_pair(top.first + a[top.second + ], top.second + ));
}
cout << pq.top().first << endl;
return ;
}

J:

Summer training round2 #6 (Training #22)的更多相关文章

  1. Summer training round2 #10(Training 30)

    A:签到题 B!:搜索+DP #include<bits/stdc++.h> #define mp make_pair #define pi pair<int,int> usi ...

  2. Summer training round2 #7 (Training #23)

    A:约瑟夫环 套公式 B:线性筛素数 C:投骰子 概率DP F:有权无向图的生成树(边最大值和最小值只差最小) 直接kruskal G:状压BFS或者双向BFS H:模拟题 I:几何题 J:高斯消元

  3. Summer training round2 #5 (Training #21)

    A:正着DFS一次处理出每个节点有多少个优先级比他低的(包括自己)作为值v[i] 求A B 再反着DFS求优先级比自己高的求C #include <bits/stdc++.h> #incl ...

  4. Summer training round2 #4 (Training #20)

    A!:UESTC1752 B!:找区间内L到R之间内的数的个数  权值分块加莫队 C!:给你一个哈斯图 去掉其中的几条边 要求输出字典序最大的拓扑排序:线段树模拟拓扑排序 D!:要求你找到最短路树并输 ...

  5. [WeChall] Training: Encodings I (Training, Encoding)

    Training: Encodings I (Training, Encoding) We intercepted this message from one challenger to anothe ...

  6. Summer training round2 #3

    A!:                    GTY系列题 B!:莫队加分块  GTY系列题 C!:线段树模拟拓扑排序(把普通的拓扑排序的栈操作改成线段树区间减一,查询区间最右侧的0的位置即可.注意一 ...

  7. Summer training round2 #1

    A:水 B:求两个三角形之间的位置关系:相交 相离 内含 ①用三个点是否在三角形内外判断    计算MA*MB.MB*MC.MC*MA的大小 若这三个值同号,那么在三角形的内部,异号在外部 #incl ...

  8. Summer training round2 #8(Training26)

    A:贪心DFS 先从最远的搜起 如果一个点的value>=2 就ans++ D:并查集 E:大模拟 F:快速幂 #include <bits/stdc++.h> using name ...

  9. Summer training round2 #9(Training28)

    A:签到题 C:模拟搜索题 #include <bits/stdc++.h> #include <cstring> #include <iostream> #inc ...

随机推荐

  1. Python--偏函数(Partial)

    Python--偏函数(Partial)   出处  https://blog.csdn.net/Appleyk/article/details/77609114 一.什么是偏函数? (1)在Pyth ...

  2. Win10+GPU版Pytorch1.1安装

    环境配置篇 安装cuda 更新nvidia驱动 打开GeForce Game Ready Driver或在 GeForce Experience中下载符合自己gpu的程序. 选择cuda 打开nvid ...

  3. Element Children

    The childNodes property contains all of the immediate children of the element. There is a significan ...

  4. jdk1.8-ArrayDeque

    一:类的继承关系 UML图 类的继承关系: )))))) ]) & ()) == ) & ()) == ) & ()] = e) ) & (); return resu ...

  5. python基础知识(字符串)

    定义字符串 ' '单引号 " "双引号  只能用于单行 '" '"三引号  可以用于多行 拼接字符串使用  +号链接 字符串只能链接字符串其他类型字符串需要用s ...

  6. 牛客小白月赛14 -A (找规律+除数取模)

    题目链接:https://ac.nowcoder.com/acm/contest/879/A 题意:有n个城市,编号1~n,k天,第一天位于城市1,要求最后一天在城市1,且相邻两天不在同一个城市,求方 ...

  7. Servlet请求和响应

    在Java Web中Servlet.请求和响应是最基本的三个对象,在Web容器的管理下,这三者能够完成基本的HTTP请求处理. Servlet的作用是为客户提供服务.servlet的角色是接受一个客户 ...

  8. Spring(十一)-- Spring代理生成器

    Spring代理生成器 1.创建需要的dao接口 2.创建需要的daoImpl实现类 3.创建前置增强类 4.创建spring.xml文件 <!-- 这个案例 需要解决的问题: 一个代理工厂 配 ...

  9. # Excel批量处理数据

    Excel批量处理数据 拖住框下拉即可得到每行+3的结果

  10. spark教程(六)-Python 编程与 spark-submit 命令

    hadoop 是 java 开发的,原生支持 java:spark 是 scala 开发的,原生支持 scala: spark 还支持 java.python.R,本文只介绍 python spark ...