codeforces616B
Dinner with Emma
Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefers elite places.
Munhattan consists of n streets and m avenues. There is exactly one restaurant on the intersection of each street and avenue. The streets are numbered with integers from 1 to n and the avenues are numbered with integers from 1 to m. The cost of dinner in the restaurant at the intersection of the i-th street and the j-th avenue is cij.
Jack and Emma decide to choose the restaurant in the following way. Firstly Emma chooses the street to dinner and then Jack chooses the avenue. Emma and Jack makes their choice optimally: Emma wants to maximize the cost of the dinner, Jack wants to minimize it. Emma takes into account that Jack wants to minimize the cost of the dinner. Find the cost of the dinner for the couple in love.
Input
The first line contains two integers n, m (1 ≤ n, m ≤ 100) — the number of streets and avenues in Munhattan.
Each of the next n lines contains m integers cij (1 ≤ cij ≤ 109) — the cost of the dinner in the restaurant on the intersection of the i-th street and the j-th avenue.
Output
Print the only integer a — the cost of the dinner for Jack and Emma.
Examples
3 4
4 1 3 5
2 2 2 2
5 4 5 1
2
3 3
1 2 3
2 3 1
3 1 2
1
Note
In the first example if Emma chooses the first or the third streets Jack can choose an avenue with the cost of the dinner 1. So she chooses the second street and Jack chooses any avenue. The cost of the dinner is 2.
In the second example regardless of Emma's choice Jack can choose a restaurant with the cost of the dinner 1.
sol:n*m模拟,这也太水了吧
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int inf=0x3f3f3f3f;
int n,m;
int main()
{
int i,j,ans=-inf;
R(n); R(m);
for(i=;i<=n;i++)
{
int tmp=inf;
for(j=;j<=m;j++) tmp=min(tmp,read());
ans=max(ans,tmp);
}
Wl(ans);
return ;
}
/*
Input
3 4
4 1 3 5
2 2 2 2
5 4 5 1
Output
2 Input
3 3
1 2 3
2 3 1
3 1 2
Output
1
*/
codeforces616B的更多相关文章
随机推荐
- Mybatis学习总结(五)——动态sql
MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么痛苦.拼接的时候要确保不能忘了必要的空格,还要注意省掉 ...
- 深入源码理解ThreadLocal和ThreadLocalMap
一.ThreadLoacl的理解: 官方的讲: ThreadLocal是一个本地线程副本变量工具类,主要用于将私有线程和该线程存放的副本对象做一个映射,各个线程之间的变量互不干扰 通俗的讲: Thre ...
- .net core 简单项目的创建
1.linux 安装net coref https://www.microsoft.com/net/learn/get-started/linuxubuntu 2.创建目录 2.创建控制台项目 第一次 ...
- day96
在服务器上部署上线项目 Linux数据库处理 首先我们需要在mysql中创建bbs库,并导入数据库SQL脚本(就是原本运行在我们项目中的数据库) 前提:需要进入mysql中 mysql> cre ...
- 立足中国,走向世界(Made in China, Go to World)
FineUI一路走来已经历经 9 年的风风雨雨,拥有国内最为广泛的捐赠群体(1500多位),和众多企业客户的青睐(200多家). 今天,我们很高兴的宣布:FineUI英文版上线了! FineUI英文版 ...
- .net core实践系列之短信服务-目录
前言 经过两周多的业余时间,终于把该系列的文章写完了.第一次写系列,可能部分关键点并没有覆盖到,如果有疑问的朋友可以随时反馈给我.另外也感谢在我发布文章时给予我方案建议与反馈源码BUG的朋友们.下面是 ...
- JVM加载类冲突,导致Mybatis查数据库返回NULL的一个小问题
今天碰到个bug,虽然小,但是有点意思 背景是SpringMVC + Mybatis的一个项目,mapper文件里写了一条sql 大概相当于 select a from tableA where b ...
- mysql常用命令行操作(二):表和库的操作、引擎、聚合函数
一.查看.创建.删除数据库 create database library default character set utf8 collate utf8_general_ci; # 创建数据库并设置 ...
- Linux reboot与init 6区别
Reboot与init 6的区别 - flyingcloud_2008的专栏 - CSDN博客https://blog.csdn.net/flyingcloud_2008/article/detail ...
- Mixing x86 with x64 code (混合编写x86和x64代码)
几个月前我小小的研究了在WOW64下的32位进程中运行native x64代码. 第二个设想是在64位进程下运行x86代码.它们都是可以的,如我google的一样, 已经有人在使用这两种方法了: ht ...