CF 604B More Cowbell#贪心
//把最大单独放,然后第二大的和最小的放一起,第三大的和第二小的放一起
//由此类推,求最大值,即为盒的最小值
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdlib>
#include<vector>
#include<stack>
#include<map>
using namespace std;
typedef long long ll; const int MAXN=100010;
const int INF=1000001;
int cow[MAXN]; int main()
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=0;i<n;i++)
scanf("%d",&cow[i]);
int minn=cow[n-1];
for(int i=0;i<n-k;i++)
minn=max(minn,cow[i]+cow[(n-k)*2-i-1]);
printf("%d\n",minn);
return 0;
}
CF 604B More Cowbell#贪心的更多相关文章
- CF 115B Lawnmower(贪心)
题目链接: 传送门 Lawnmower time limit per test:2 second memory limit per test:256 megabytes Description ...
- CF Soldier and Badges (贪心)
Soldier and Badges time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- CF Anya and Ghosts (贪心)
Anya and Ghosts time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- codeforces 604B More Cowbell
题目链接:http://codeforces.com/contest/604/problem/B 题意:n个数字,k个盒子,把n个数放入k个盒子中,每个盒子最多只能放两个数字,问盒子容量的最小值是多少 ...
- cf 853 A planning [贪心]
题面: 传送门 思路: 一眼看得,这是贪心[雾] 实际上,我们要求的答案就是sigma(ci*(ti-i))(i=1~n),这其中sigma(ci*i)是确定的 那么我们就要最小化sigma(ci*t ...
- CF 1082E Increasing Frequency(贪心)
传送门 解题思路 贪心.对于一段区间中,可以将这段区间中相同的元素同时变成\(c\),但要付出的代价是区间中等于\(c\)的数的个数,设\(sum[i]\)表示等于\(c\)数字的前缀和,Max[i] ...
- cf 12C Fruits(贪心【简单数学】)
题意: m个水果,n个价格.每种水果只有一个价格. 问如果给每种水果分配价格,使得买的m个水果总价格最小.最大. 输出最小值和最大值. 思路: 贪心. 代码: bool cmp(int a,int b ...
- CF 161B Discounts(贪心)
题目链接: 传送门 Discounts time limit per test:3 second memory limit per test:256 megabytes Description ...
- CF 268E Playlist(贪心)
题目链接: 传送门 Playlist time limit per test:1 second memory limit per test:256 megabytes Description ...
随机推荐
- python中的编码声明
python中的第一行,目的就是指出,你想要你的这个文件中的代码用什么可执行程序去运行它,就这么简单 #!/usr/bin/python 相当于写死了 python 路径(是告诉OS执行这个py时,调 ...
- Base64加密与解密
import sun.misc.BASE64Decoder;import sun.misc.BASE64Encoder; // 将 str进行 BASE64 编码 public static Stri ...
- 文档在线预览开源实现方案二:OpenOffice + pdf.js
文档在线预览的另一种实现方式采用的技术栈是OpenOffice + pdf.js, office文档转换为pdf的工作依然由OpenOffice的服务来完成,pdf生成后我们不再将其转换为其他文件而是 ...
- java--调整JVM内存的大小
默认占用:64M的内存 修改内存的方式: 1.某一类,右键选择--Run Configurations 2.选择--Arguments 3.在VM argments中输入内容,如:-Xmx80m
- Cracking the Coding Interview 第二章
2.2 链表中倒数第k个结点 输入一个链表,输出该链表中倒数第k个结点. 思路:快慢指针(error: 判断是否有可行解,否则返回null, while, if 后加空格) /* public cla ...
- struts2.0中struts.xml配置文件详解
先来展示一个配置文件 <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration ...
- CodeForces 685B Kay and Snowflake
树的重心,树形$dp$. 记录以$x$为$root$的子树的节点个数为$sz[x]$,重儿子为$son[x]$,重心为$ans[x]$. 首先要知道一个结论:以$x$为$root$的子树的重心$ans ...
- C++ static与单例模式
单例模式是应用最多的一种设计模式,它要求系统中每个类有且只能有一个实例对象. 主要优点: 1.提供了对唯一实例的受控访问. 2.由于在系统内存中只存在一个对象,因此可以节约系统资源,对于一些需要频繁创 ...
- String、StringBuffer和StringBuilder区别及性能分析
1.性能比较:StringBuilder > StringBuffer > String 2.String <(StringBuffer,StringBuilder)的原因 S ...
- git在webstorm中的使用
打开webstorm新建项目,这里新建的项目名称我起为lianxi 打开设置选项里的插件栏 搜索gitignore,并安装,我这里已安装,所以显示X,没有安装的会显示一个绿色的下载箭头.安装完后需要重 ...