Summer training round2 #6 (Training #22)
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)的更多相关文章
- Summer training round2 #10(Training 30)
A:签到题 B!:搜索+DP #include<bits/stdc++.h> #define mp make_pair #define pi pair<int,int> usi ...
- Summer training round2 #7 (Training #23)
A:约瑟夫环 套公式 B:线性筛素数 C:投骰子 概率DP F:有权无向图的生成树(边最大值和最小值只差最小) 直接kruskal G:状压BFS或者双向BFS H:模拟题 I:几何题 J:高斯消元
- Summer training round2 #5 (Training #21)
A:正着DFS一次处理出每个节点有多少个优先级比他低的(包括自己)作为值v[i] 求A B 再反着DFS求优先级比自己高的求C #include <bits/stdc++.h> #incl ...
- Summer training round2 #4 (Training #20)
A!:UESTC1752 B!:找区间内L到R之间内的数的个数 权值分块加莫队 C!:给你一个哈斯图 去掉其中的几条边 要求输出字典序最大的拓扑排序:线段树模拟拓扑排序 D!:要求你找到最短路树并输 ...
- [WeChall] Training: Encodings I (Training, Encoding)
Training: Encodings I (Training, Encoding) We intercepted this message from one challenger to anothe ...
- Summer training round2 #3
A!: GTY系列题 B!:莫队加分块 GTY系列题 C!:线段树模拟拓扑排序(把普通的拓扑排序的栈操作改成线段树区间减一,查询区间最右侧的0的位置即可.注意一 ...
- Summer training round2 #1
A:水 B:求两个三角形之间的位置关系:相交 相离 内含 ①用三个点是否在三角形内外判断 计算MA*MB.MB*MC.MC*MA的大小 若这三个值同号,那么在三角形的内部,异号在外部 #incl ...
- Summer training round2 #8(Training26)
A:贪心DFS 先从最远的搜起 如果一个点的value>=2 就ans++ D:并查集 E:大模拟 F:快速幂 #include <bits/stdc++.h> using name ...
- Summer training round2 #9(Training28)
A:签到题 C:模拟搜索题 #include <bits/stdc++.h> #include <cstring> #include <iostream> #inc ...
随机推荐
- Spark内核源码解析
1.spark内核架构常用术语 Application:基于spark程序,包含一个driver program(客户端程序)和多个executeor(线程) Driver Progrom:代表着sp ...
- webdriervAPI(XPath元素定位)
from selenium import webdriver driver = webdriver.Chorme() driver.get("http://www.baidu.co ...
- 【DSP开发】HyperLink 编程和性能考量
冯华亮/Brighton Feng---Communication Infrastructure 摘要 HyperLink 为两个 KeyStone 架构 DSP 之间提供了一种高速,低延迟,引脚数量 ...
- python 爬虫 urllib模块 url编码处理
案例:爬取使用搜狗根据指定词条搜索到的页面数据(例如爬取词条为‘周杰伦’的页面数据) import urllib.request # 1.指定url url = 'https://www.sogou. ...
- 友善的树形DP
一棵树,如果有序点对(x,y)之间路径的长度取模于3==0,那么ans0便加上这个长度: 如果取模于3==1,那么ans1便加上这个长度: 如果取模于3==2,那么ans2便加上这个长度: 让你求an ...
- <<C++ Primer>> 第 6 章 函数
术语表 第 6 章 函数 二义性调用(ambiguous call): 是一种编译时发生的错误,造成二义性调用的原因时在函数匹配时两个或多个函数提供的匹配一样好,编译器找不到唯一的最佳匹配. 实 ...
- HYSBZ 1797 Mincut 最小割
Descrption A,B两个国家正在交战,其中A国的物资运输网中有N个中转站,M条单向道路.设其中第i (1≤i≤M)条道路连接了vi,ui两个中转站,那么中转站vi可以通过该道路到达ui中转站, ...
- git diff 命令介绍
https://www.jianshu.com/p/6e1f7198e76a https://www.jianshu.com/p/5b6a014ac3db https://blog.csdn.net/ ...
- python基础_面向对象进阶
@property装饰器 之前我们讨论过Python中属性和方法访问权限的问题,虽然我们不建议将属性设置为私有的,但是如果直接将属性暴露给外界也是有问题的,比如我们没有办法检查赋给属性的值是否有效.我 ...
- 从入门到自闭之Python函数初识
函数初识 定义:def--关键字 将某个功能封装到一个空间中就是一个函数 功能: 减少重复代码 函数的调用 函数名+():调用函数和接收返回值 函数的返回值 return 值 == 返回值 ...