Ural 2069 Hard Rock

2023-10-06 19:02
文章标签 hard ural 2069 rock

本文主要是介绍Ural 2069 Hard Rock,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=2069
题意:给你n条竖线m条横线,让你求,从右上角到左下角的所有路线的每条路线中的最小值最大,输出最大值
解析:根据给出的这个图的特点,竖着的线值是一样的,横着的线是一样的,路线总共有四种情况:
1、竖到底再横着走。
2、横到底再竖着走。
3、先横着走,再竖着走竖着的线里面最大的,再横着走。
4、先竖着走,再横着走横着的线里面最大的,再竖着走

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn = 2*1e5+100;
int clo[maxn];
int row[maxn];
int main()
{int n,m;scanf("%d %d",&n,&m);int maxc=0,maxr=0;for(int i=0;i<n;i++){scanf("%d",&row[i]);maxr = max(maxr,row[i]);}for(int i=0;i<m;i++){scanf("%d",&clo[i]);maxc = max(maxc,clo[i]);}int ans = min(row[0],clo[m-1]);ans = max(ans,min(clo[0],row[n-1]));ans = max(ans,min(maxr,min(clo[0],clo[m-1])));ans = max(ans,min(maxc,min(row[n-1],row[0])));printf("%d\n",ans);return 0;
}

这篇关于Ural 2069 Hard Rock的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/153782

相关文章

ural 1297. Palindrome dp

1297. Palindrome Time limit: 1.0 second Memory limit: 64 MB The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unli

ural 1149. Sinus Dances dfs

1149. Sinus Dances Time limit: 1.0 second Memory limit: 64 MB Let  An = sin(1–sin(2+sin(3–sin(4+…sin( n))…) Let  Sn = (…( A 1+ n) A 2+ n–1) A 3+…+2) An+1 For given  N print  SN Input One

ural 1820. Ural Steaks 贪心

1820. Ural Steaks Time limit: 0.5 second Memory limit: 64 MB After the personal contest, happy but hungry programmers dropped into the restaurant “Ural Steaks” and ordered  n specialty steaks

ural 1017. Staircases DP

1017. Staircases Time limit: 1.0 second Memory limit: 64 MB One curious child has a set of  N little bricks (5 ≤  N ≤ 500). From these bricks he builds different staircases. Staircase consist

ural 1026. Questions and Answers 查询

1026. Questions and Answers Time limit: 2.0 second Memory limit: 64 MB Background The database of the Pentagon contains a top-secret information. We don’t know what the information is — you

ural 1014. Product of Digits贪心

1014. Product of Digits Time limit: 1.0 second Memory limit: 64 MB Your task is to find the minimal positive integer number  Q so that the product of digits of  Q is exactly equal to  N. Inpu

HDU 1097 A hard puzzle(规律)

题目: http://acm.hdu.edu.cn/showproblem.php?pid=1097 题意: 求a的b次方的最后一位。 题解: 直接从例子入手, 第一组数据 7 66,结果如下(只要最后一位所以模10) 7 9 3 1 7 9··· 循环节为4,即结果在4个数值内循环出现。 第二组数据 6 800,结果如下 6 6 6 6··· 循环节为1 ···

后缀数组 - 求最长回文子串 + 模板题 --- ural 1297

1297. Palindrome Time Limit: 1.0 second Memory Limit: 16 MB The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent from the competing «Robots Unlim

【URAL】1057 Amount of Degrees 数位DP

传送门:【URAL】1057 Amount of Degrees 题目分析:将数转化成能达到的最大的01串,串上从右往左第i位为1表示该数包括B^i。 代码如下: #include <cstdio>#include <cstring>#include <algorithm>using namespace std ;typedef long long LL ;#de

P problem、NP problem、NP-complete problem、NP-hard problem是什么

时间复杂度并不是表示一个程序解决问题需要花多少时间,而是当程序所处理的问题规模扩大后,程序需要的时间长度对应增长得有多快。 一、多项式时间(Polynomial time) 多项式复杂度 容易看出,前面的几类复杂度被分为两种级别,其中后者的复杂度无论如何都远远大于前者。 像等,我们把它叫做多项式级复杂度,因为它的规模n出现在底数的位置; 非多项式级的复杂度 另一种像是等,它