Maximum of Maximums of Minimums CodeForces - 872B(思维)

Pythia: A Customizable Hardware Prefetching Framework Using Online Reinforcement Learning——“预取”论文解读 参考传送门: 1. Hardware Prefetching笔记 2. 全球百科——缓存预取 3. 百度百科——缓存数据预期技术 目录0. 什么是Hardware Prefetching(本节内容不包括在论文中)1. 简介1.1 关于Hardware Prefetching的一些关键信息1.2 现阶段方法的缺陷1.3 论文团队的目标1.4 核心思想2. 必要的背景知识介绍2.1 强化学习(Reinforcement learning)2.2 为什么说强化学习是一个好的解决思路3. 解决方法与思路3.1 Py 阅读详情

Maximum of Maximums of Minimums

CodeForces - 872B

You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the k obtained minimums. What is the maximum possible integer you can get?

Definitions of subsegment and array splitting are given in notes.


Input

The first line contains two integers n and k (1 ≤ k ≤ n ≤  105) — the size of the array a and the number of subsegments you have to split the array to.

The second line contains n integers a1,  a2,  ...,  an ( - 109  ≤  ai ≤  109).

Output

Print single integer — the maximum possible integer you can get if you split the array into k non-empty subsegments and take maximum of minimums on the subsegments.

Examples
Input
5 2
1 2 3 4 5
Output
5
Input
5 1
-4 -5 -3 -2 -1
Output
-5
Note

A subsegment [l,  r] (l ≤ r) of array a is the sequence al,  al + 1,  ...,  ar.

Splitting of array a of n elements into k subsegments [l1, r1], [l2, r2], ..., [lk, rk] (l1 = 1, rk = n, li = ri - 1 + 1 for all i > 1) is k sequences (al1, ..., ar1), ..., (alk, ..., ark).

In the first example you should split the array into subsegments [1, 4] and [5, 5] that results in sequences (1, 2, 3, 4) and (5). The minimums are min(1, 2, 3, 4) = 1 and min(5) = 5. The resulting maximum is max(1, 5) = 5. It is obvious that you can't reach greater result.

In the second example the only option you have is to split the array into one subsegment [1, 5], that results in one sequence ( - 4,  - 5,  - 3,  - 2,  - 1). The only minimum is min( - 4,  - 5,  - 3,  - 2,  - 1) =  - 5. The resulting maximum is  - 5.

题意, 给出一个长度为n的数组, 将其分为连续的k个子集, 为k个子集中最大的最小值是多少?(求出每个子集的最小值, 再求出k个最小值中的最大值);
当k==1时, 只有原序列, 输出最小值;
当k==2时, 输出a[0], a[n-1]中最大值;

当k>2时, 输出最大值;

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int INF = 0x7fffffff;
const int maxn = 1e5+10;
int main(){
    int n,k;
    cin >> n >> k;
    int a[maxn];
    int maxv = -INF,minv = INF;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        maxv = max(a[i],maxv);
        minv = min(a[i],minv);
    }
    if(k == 1) printf("%d\n",minv);
    if(k == 2) printf("%d\n",max(a[1],a[n]));
    if(k > 2) printf("%d\n",maxv);
    return 0;
}




人工智能之数学基础:弄懂数学本质,让我们不再害怕数学 数学的用途远远超过了人们的想象,甚至无处不在,任何领域都需要用到数学知识,人工智能也不例外。我将尽可能地将数学知识和机器学习算法相结合,让大家知道这些数学知识咋人工智能领域中的应用,使得数学的学习不会过于枯燥,同时也帮助大家扫清在学习算法过程中的数学障碍。除此之外,我还希望帮助大家建立一种不一样的数学思维,不再将数学看成是符号的演算、公式的推导,而是将数学看成是一种描述这个世界的工具,这样你就会发现这个世界处处有数学。当我们面对问题的时候,你是否会对问题进行抽象,然后通过数学来解决问题? 阅读详情

相关推荐

Win10 Rational Rose 安装教程

在此教程中我们需要四个文件,点此下载[提取码:ig33] 其中第一个为2007的安装包,第二个为破解文件 前言 很多小伙伴反应说会出现几天后就到期的问题,包括我也出现了该问题,如果你已在其他地方安装好了文件且破解成功,且但几天后到期,如果可以使用更改时间的方式打开,那么可以跳过接下来的教程,直接看第三节,我们采用批处理的形式一键完成从修改时间到打开最后改回来的方法解决此问题 一、安装软件 解压缩两个安装包,进入 Rational Rose文件夹 选择setup.exe开始安装 按照图示依次点击

CoderJiang 2万+

C - Maximum of Maximums of Minimums(数学)

C - Maximum of Maximums of Minimums You are given an arraya1, a2, ..., anconsisting ofnintegers, and an integerk. You have to split the array into exactlyknon-empty subsegments. You'll then...

weixin_30613433的博客 181

从0到1做AI漫剧:即梦+豆包+剪映+红果全流程实战

AI视频生成正在重塑内容创作的生产方式,它让原本高门槛的影视制作,变成了一条由文本、画面、剪辑与分发环节协同的流水线。理解其底层原理,在于将大模型的语义理解、图像生成与视频合成能力,与工程化的流程管理相结合,从而实现从创意到成片的自动化输出。这种技术的价值,不仅体现在降低制作成本,更在于让个人创作者能够独立完成高质量短剧,并快速迭代内容。在短剧、短视频、广告营销等场景中,利用即梦生成画面、豆包编写剧本、剪映完成剪辑、红果进行分发的组合,已成为一种被广泛验证的实践路径。本文聚焦AI漫剧制作,从环境准备、分镜设

weixin_34072637的博客 380

Codeforces 872 B Maximum of Maximums of Minimums

题目地址 题意:给你一个序列,然后让你把这个序列正好分割为k个子序列,每个子序列都选出一个最小值,然后求这些最小值的最大值为多少。 思路:这题就是考细节的,我在比赛中被hack了两次,然后最后一次hack还是在比赛结束以后的重测中。言归正传,我们可以发现存在以下的三种情况: m==1,这时候因为只能选1个子序列就是原序列了,所以就是输出最小值了。 m==2,这时候我们可以发现要分割为两个集合,所

不要錯過才珍惜 781

5.FxBlue跟单常见问题

fxblue喊单ea和fxblue跟单会在mt4/mt5客户端ea栏目里记录fxblue在跟单复制订单过程中的全面记录。在遇到问题时,我们首先要恢复默认参数尝试,然后再到ea栏找报错提示。 ​ 需要注意的是,是EA选项卡,而不是日志选项卡。 此外,您可以在 MT4/5 软件终端面板的"EA"选项卡中查看跟单记录,您可以通过右键单击 Experts 日志并从 MT4/5 的弹出菜单中选择“打开”来打开每日日志文件以及历史文件。 5.1 No “heartbeat” received 没有收到“心跳” 接收方

weixin_44406393的博客 1872

VMware 虚拟机里连不上网的五种解决方案

在VMware虚拟机里的虚拟机系统连接不上网络 首先,注意查看适配器选项里的网络连接这两个网络连接是否存在,如果不存在可以重新装一下VM 如果存在,连不上网 解决办法一: 虚拟机设置里,找到“网络适配器”,右边的网络连接选择“NAT 模式”,如果不行的话再linux系统。还是不行的话接着看第二种解决方案。 解决方法二: 可能原因是VMware NET Service...

墨轩 18万+

Codeforce - 872 - B. Maximum of Maximums of Minimums【思维+贪心】

B. Maximum of Maximums of Minimumstime limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard outputYou are given an array a1, a2, …, an consisting of n integer

nobleman 1805

从零开始!在 Windows 上安装与配置 Dify

这篇博客将详细介绍如何在 Windows 系统上部署 Dify,适合零基础用户。从 Docker 和 WSL 的安装配置开始,逐步指导用户设置 Git、Docker 环境以及 Dify 配置文件,解决可能遇到的端口冲突等问题,最终完成 Dify 的启动和测试。通过简明易懂的步骤,帮助用户在本地成功运行 Dify,实现模型供应商配置,让 Dify 项目在 Windows 平台上顺利上线。

qq_49035156的博客 5万+

【Codeforces Round #440 (Div. 2) B】Maximum of Maximums of Minimums

B. Maximum of Maximums of Minimumstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a1, a2, ..., an consisting of n integers, ...

keep coding 545

Android AudioFlinger(一)——初识AndroidAudio Flinger

AudioFlinger 是 Android 系统中的音频中间层(audio HAL, Audio Hardware Abstraction Layer)的一部分,负责管理音频的混音、播放和音量控制等功能。它充当 Android 应用程序和音频硬件之间的桥梁。

hirezy 1664

硬核干货|C#+EtherCAT协议:高精度多轴伺服运动控制通信实战

本文摘要: 文章聚焦工业自动化领域多轴伺服运动控制的高精度与实时性需求,基于C#与EtherCAT协议实现完整解决方案。EtherCAT凭借微秒级同步、分布式架构等优势成为首选,而C#通过优化GC策略和实时线程可满足工业控制要求。文章从工程落地角度,详细拆解EtherCAT的PDO/SDO通信机制与多轴同步控制逻辑,提供完整的C#代码实现(主站初始化、伺服配置、运动控制等),所有代码均通过汇川/松下伺服实测验证。核心亮点包括:纯C#原生开发、工业现场高频问题解决方案、硬件适配指南,帮助开发者快速掌握高精度多

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 575

Maximum of Maximums of Minimums codeforces 872 B(简单思路)

题意:给你一个数组,长度为n,要你把数组分为k组,注意每一组都必须要是连续的,从每段里面取最小值,然后从k个最小值里面找出最大值就是答案。 #include&lt;stdio.h&gt; #include&lt;algorithm&gt; using namespace std; const int N=1e5+5; int a[N],maxa,mina; int main() { i...

Never__give__up的博客 450

嵌入式工程师成长之路(0)----认识元件

在电子设计与维修中,认识元件是成功的关键!面对琳琅满目的电阻、电容、电感与二极管,样子形式千奇百怪,你是否也曾陷入困难? 本文基于行业权威分类标准,结合十年工程师实战经验,深度解析4大类、30+子类电子元件的核心特性、应用场景与避坑指南,助你从“小白”秒变“电子高手”!

云轩阁 11万+

Codeforces 872B:Maximum of Maximums of Minimums(思维)

B. Maximum of Maximums of Minimums You are given an arraya1, a2, ..., anconsisting ofnintegers, and an integerk. You have to split the array into exactlyknon-empty subsegmen...

weixin_30339969的博客 142

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Maximum of Maximums of Minimums CodeForces - 872B 线段树 / 思维

You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each sub...

还我笑颜 217

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Maximum of Maximums of Minimums CodeForces - 872B

Maximum of Maximums of Minimums 题目链接:CodeForces - 872B题意, 给出一个长度为n的数组, 将其分为连续的k个子集, 为k个子集中最大的最小值是多少?(求出每个子集的最...

Sirius_han的博客 284

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

CodeForces - 872B Maximum of Maximums of Minimums RMQ

CodeForces - 872B Maximum of Maximums of Minimums RMQ http://codeforces.com/contest/872/problem/B 题意:将一个数组连续的分成k块,每块中取最小值。求这k个最小值中的最大值。 题解:①分成一个的情况:就是最小那个,②分成两个的情况:暴力即可,我用了rmq,没在意负数初始化成-1了。。。③k大于3的情况,把最大的那个数分成独立的一组即可。

ACZone 404

codeforces 872 B. Maximum of Maximums of Minimums

http://www.elijahqi.win/archives/1255 You are given an array a1, a2, …, an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You’ll then co...

Elijahqi 264

Codeforces--872B--Maximum of Maximums of Minimums

题目描述: You are given an array a1, a2, …, an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You’ll then compute the minimum integer on each...

猩猩是个好程序员的博客 196

CodeForces 872B Maximum of Maximums of Minimums

题目链接:http://codeforces.com/contest/872/problem/B 题意:给你一个长度为n序列,让你把他准确分为k个子序列,让你求每个子序列的最小后,再求这些最小值中的最大值,输出那个可能的最大的最大值 解析:如果k>=3肯定是直接输出序列的最大值,如果k==1,肯定输出序列的最小值,如果等于0,那么你只需要比较一下第一个和最后一个大小,选择大的那个输出即可,因为你

22h's Blog 554

Maximum of Maximums of Minimums CodeForces - 872B---小shi shi 给小天天的 Day2

You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each sub...

短发 306

Codeforces Round #440 B. Maximum of Maximums of Minimums-【思维】

传送门:http://codeforces.com/contest/872/problem/B B. Maximum of Maximums of Minimums time limit per test 1 second memory limit per test 256 megabytes input standard input o

jadeyansir的博客 286

Codeforces Round #440 B. Maximum of Maximums of Minimums

题目链接:http://codeforces.com/contest/872/problem/B 题目大意:给你一个长度为n的数组,要求将它分成连续的k份,这k份每个都有一个最小值,然后再对最小值取最大值,现在要求能够获得的最终值的最大值是多少 思路:显然要得到最大值,那么我们让最大值单独成一份就好了。也就是说只要k≥3,我们总是令最大值单独成一份,其他随意分,就可以得到最大值,并且这个最

可我只是梦呓,半生半生的无力 219

codeforce Maximum of Maximums of Minimums(区间划分 求区间最小值最大值问题)

http://codeforces.com/problemset/problem/872/B 题意: 给你n个数,和k,让你把这n个数(连续)划分成k个区间,每个区间都选择一个最小值,让后让你从最小值中的最大值最大。 思路:当k等于1的时候,我们直接输出最小值就好,当k大于3的时候,我们直接输出一个最大值,因为k大于3的时候我们可以让最大值孤立起来,那么只需要讨论一下 当K等于

wjmwsgj的博客 1279

Maximum of Maximums of Minimums

点击打开链接 You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integ

hpuw1234的博客 610

C - Maximum of Maximums of Minimums

You are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on eac

gtuif的博客 665
上一篇: Balanced Substring CodeForces - 873B (思维+前缀和)
下一篇: Continuous Login ZOJ - 3768 (暴力)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值