Dinner with Emma

CodeForces - 616B

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

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

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的更多相关文章

随机推荐

  1. WPF---Binding学习(一)

    转自:http://blog.csdn.net/lisenyang/article/details/18312199 1,Data Binding在WPF中的地位 程序的本质是数据+算法.数据会在存储 ...

  2. WPF(一)

    什么是WPF WPF(Windows Presentation Foundation)是用于Windows的现代图形显示系统.与之前出现的技术相比,WPF发生了根本性变化.WPF引用了"内置 ...

  3. maven笔记-将本地jar包打包进可执行jar中

    参考资料:http://www.cnblogs.com/richard-jing/archive/2013/01/27/Maven_localjar.html 使用本地jar <dependen ...

  4. Java使用Future设置方法超时

    1.使用线程包 java.util.concurrent.Future 2.Future代表一个异步计算的结果. 它提供了方法来检查是否计算已经完成,还是正在计算而处于等待状态,并且也提供了获取计算结 ...

  5. C#邮件发送类 简单实用 可自定义发件人名称

    上图看效果 MailHelper: public class MailHelper { public bool SendMail(MailSender sender,out string errorM ...

  6. 史上最全面的Elasticsearch使用指南

    Elasticsearch使用指南 Elasticsearch使用指南 前言 ES是什么 什么是全文检索 ES的应用场景 ES的存储结构 第一章:安装 1.下载 2.解压 3.配置 4.启动 5.查看 ...

  7. Sql 调优总结

    1前言 Sql 语句调优对应用性能非常重要,看了几篇文章,总结了一下数据库优化的方法. 2 数据库 Sql 优化 1 对查询进行优化,要尽量避免全表扫描,首先应考虑在 where 及 order by ...

  8. 窥探ASP.Net MVC底层原理 实现跨越Session的分布式TempData

    1.问题的引出 我相信大家在项目中都使用过TempData,TempData是一个字典集合,一般用于两个请求之间临时缓存数据或者页面之间传递消息.也都知道TempData是用Session来实现的,既 ...

  9. Sampling Matrix

    这些天看了一些关于采样矩阵(大概是这么翻译的)的论文,简单做个总结. FAST MONTE CARLO ALGORITHMS FOR MATRICES I: APPROXIMATING MATRIX ...

  10. WinRAR从入门到高级的操作技巧集合

    一.基础技巧 1.批量建立文件夹 如果在工作中,经常要建立很多相同文件夹结构(如在备份数据时).那可以把这个繁琐的工作让WinRAR完成:先在“资源管理器”中把多个文件夹结构建好(包括其下的子文件夹) ...