Ilya is a frontman of the most famous rock band on Earth. Band decided to make the most awesome music video ever for their new single. In that music video Ilya will go through Manhattan standing on the top of a huge truck and playing amazing guitar solos. And during this show residents of the island will join in singing and shaking their heads. However, there is a problem. People on some streets hate rock.
Recall that Manhattan consists of n vertical and m horizontal streets which form the grid of ( n − 1)×( m − 1) squares. Band’s producer conducted a research and realized two things. First, band’s popularity is constant on each street. Second, a popularity can be denoted as an integer from 1 to 10 9. For example, if rockers go along the street with popularity equal to 10 9 then people will greet them with a hail of applause, fireworks, laser show and boxes with... let it be an orange juice. On the other hand, if rockers go along the street with popularity equal to 1 then people will throw rotten tomatoes and eggs to the musicians. And this will not help to make the most awesome music video!
So, a route goes from the upper left corner to the bottom right corner. Let us define the route coolness as the minimal popularity over all streets in which rockers passed non-zero distance. As you have probably guessed, the musicians want to find the route with the maximal coolness. If you help them then Ilya will even give you his autograph!

Input

In the first line there are integers n and m (2 ≤ nm ≤ 10 5), separated by space. These are the numbers of vertical and horizontal streets, respectively.
In the following n lines there are popularity values (one value on each line) on vertical streets in the order from left to right.
In the following m lines there are popularity values (one value on each line) on horizontal streets in the order from top to bottom.
It is guaranteed that all popularity values are integers from 1 to 10 9.

Output

Output a single integer which is a maximal possible route coolness.

Example

input output
2 3
4
8
2
7
3
4
4 3
12
4
12
3
21
5
16
12

解题思路:

题意:求从左上角刀右下角所经过街道的最小的权值,直接分成4种情况:不好描述,直接看代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
int m,n,i,a[],b[];
cin>>m>>n;
int maxn = -,maxm = -;
for(i=;i<m;i++){
cin>>a[i];
if(a[i]>maxn&&i!=m-&&i!=)
maxn = a[i];
}
for(i=;i<n;i++){
cin>>b[i];
if(b[i]>maxm&&i!=n-&&i!=) maxm = b[i];
}
int min1 = min(b[],a[m-]);
int min2 = min(a[],b[n-]);
int min3 = min(a[],min(maxm,a[m-]));
int min4 = min(b[],min(maxn,b[n-]));
//cout<<min1<<min2<<min3<<min4<<endl;
int ans = max(max(min1,min2),max(min3,min4));
cout<<ans<<endl;
return ;
}

Hard Rock的更多相关文章

  1. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  2. POJ - 2339 Rock, Scissors, Paper

    初看题目时就发了个错误,我因为没有耐心看题而不了解题目本身的意思,找不到做题的突破口,即使看了一些题解,还是没有想到方法. 后来在去问安叔,安叔一语道破天机,问我有没有搞清题目的意思,我才恍然大悟,做 ...

  3. ROCK 聚类算法‏

    ROCK (RObust Clustering using linKs)  聚类算法‏是一种鲁棒的用于分类属性的聚类算法.该算法属于凝聚型的层次聚类算法.之所以鲁棒是因为在确认两对象(样本点/簇)之间 ...

  4. Rice Rock

    先翻译评分要点,然后一点点翻译程序实现过程 如何产生一堆岩石? rock_group = set([])#空集合,全局变量   rock_group.add(a_rock) 要画出来draw hand ...

  5. HDOJ(HDU) 2164 Rock, Paper, or Scissors?

    Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...

  6. The Rock Game

    Before the cows head home for rest and recreation, Farmer John wantsthem to get some intellectual st ...

  7. 弹指之间 -- Folk Rock

    CHAPTER 17 民谣摇滚 Folk Rock 以8Beat为主,120左右的速度最能表现此节奏特色. 示例曲目: 略

  8. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  9. HDU 2164 Rock, Paper, or Scissors?

    http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...

随机推荐

  1. 16-(基础入门篇)GPRS(Air202)关于多个文件中的变量调用和定时器

    https://www.cnblogs.com/yangfengwu/p/9968405.html 因为自己看到好多问多个文件调用的,感觉这个应该说一说 对了大家有没有知道这个是干什么的 大家有没有看 ...

  2. Intel Artificial Intelligence Conference(2018.11.14)

    时间:2018.11.14地点:北京国贸大酒店

  3. kettle学习笔记——插件的安装与使用

    一.概述 暂略 二.ODPS插件 https://yq.aliyun.com/articles/68911

  4. RNN介绍,较易懂

    人类并不是每时每刻都从一片空白的大脑开始他们的思考.在你阅读这篇文章时候,你都是基于自己已经拥有的对先前所见词的理解来推断当前词的真实含义.我们不会将所有的东西都全部丢弃,然后用空白的大脑进行思考.我 ...

  5. python语言程序设计3

    1, 起码坚持每天  半小时吧... 2, 上面有常用的几个数据类型..整数类型和字符串类型还行,但是列表类型的话就很蛋疼了. 3, 字符串类型的显著特点是在两侧有单引号或者双引号.用单引号和双引号表 ...

  6. Ext JS 4 的类系统

    前言 我们知道,JavaScript中没有真正的类,它是一种面向原型的语言 .这种语言一个强大的特性就是灵活,实现一个功能可以有很多不同的方式,用不同的编码风格和技巧.但随之也带来了代码的不可预测和难 ...

  7. Canary机制的绕过

    目标程序下载 提取码:8ypi 1.检查程序开启了哪些安全保护机制 Canary与NX开启了 Canary机制简介 64位的canary机制,会在函数头部添加: mov rax,QWORD PTR f ...

  8. php5.6安装Zend Opcache扩展

    假设php5.6安装路径为/data2/php[root@nextcloud src]# pwd/usr/local/src[root@nextcloud src]# wget http://pecl ...

  9. Nginx+keepalived 双机热备(主主模式)

    之前已经介绍了Nginx+Keepalived双机热备的主从模式,今天在此基础上说下主主模式的配置. 由之前的配置信息可知:master机器(master-node):103.110.98.14/19 ...

  10. linux下expect环境安装以及简单脚本测试

    expect是交互性很强的脚本语言,可以帮助运维人员实现批量管理成千上百台服务器操作,是一款很实用的批量部署工具!expect依赖于tcl,而linux系统里一般不自带安装tcl,所以需要手动安装 下 ...