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
  1. 3 4
    4 1 3 5
    2 2 2 2
    5 4 5 1
Output
  1. 2
Input
  1. 3 3
    1 2 3
    2 3 1
    3 1 2
Output
  1. 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模拟,这也太水了吧

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int ll;
  4. inline ll read()
  5. {
  6. ll s=;
  7. bool f=;
  8. char ch=' ';
  9. while(!isdigit(ch))
  10. {
  11. f|=(ch=='-'); ch=getchar();
  12. }
  13. while(isdigit(ch))
  14. {
  15. s=(s<<)+(s<<)+(ch^); ch=getchar();
  16. }
  17. return (f)?(-s):(s);
  18. }
  19. #define R(x) x=read()
  20. inline void write(ll x)
  21. {
  22. if(x<)
  23. {
  24. putchar('-'); x=-x;
  25. }
  26. if(x<)
  27. {
  28. putchar(x+''); return;
  29. }
  30. write(x/);
  31. putchar((x%)+'');
  32. return;
  33. }
  34. #define W(x) write(x),putchar(' ')
  35. #define Wl(x) write(x),putchar('\n')
  36. const int inf=0x3f3f3f3f;
  37. int n,m;
  38. int main()
  39. {
  40. int i,j,ans=-inf;
  41. R(n); R(m);
  42. for(i=;i<=n;i++)
  43. {
  44. int tmp=inf;
  45. for(j=;j<=m;j++) tmp=min(tmp,read());
  46. ans=max(ans,tmp);
  47. }
  48. Wl(ans);
  49. return ;
  50. }
  51. /*
  52. Input
  53. 3 4
  54. 4 1 3 5
  55. 2 2 2 2
  56. 5 4 5 1
  57. Output
  58. 2
  59.  
  60. Input
  61. 3 3
  62. 1 2 3
  63. 2 3 1
  64. 3 1 2
  65. Output
  66. 1
  67. */

codeforces616B的更多相关文章

随机推荐

  1. DES对称加密算法详解和c++代码实现(带样例和详细的中间数据)

    特点: 1.DES是对称性加密算法,即加密和解密是对称的,用的是同一个密钥 2.DES只处理二进制数据,所以需要将明文转换成为2进制数据 3.DES每次处理64位的数据,所以应该将明文切割成64位的分 ...

  2. 搭建SpringBoot+dubbo+zookeeper+maven框架(四)

    今天我们完成框架的thymeleaf模板显示页面功能,页面的用户登陆,密码的AES加密解密,输错3次进行验证码验证功能,东西可能比较多,这个是我这两天在网上结合各种资源整合出来的,基本功能都已经实现, ...

  3. kmeans聚类理论篇

    前言 kmeans是最简单的聚类算法之一,但是运用十分广泛.最近在工作中也经常遇到这个算法.kmeans一般在数据分析前期使用,选取适当的k,将数据分类后,然后分类研究不同聚类下数据的特点. 本文记录 ...

  4. Python中for循环搭配else的陷阱

    假设有如下代码: for i in range(10): if i == 5: print 'found it! i = %s' % i else: print 'not found it ...' ...

  5. ASP.NET MVC5+EF6+EasyUI 后台管理系统(91)-EF 连接 MySql

    前言 虽然系统目前只支持MSSQL版本,但是很多朋友公司技术规定必须使用MySql,下面我们就来使用EF连接MySQL吧! (1)安装MYSQL环境 1.下载安装MYSQL数据,这里我们安装phpSt ...

  6. websockect外网无法访问问题

    项目在测试环境可以正常使用websockect,然而把项目发布到公网上却无法使用问题. 有几种解决方案,1.防火墙未加入入站规则,否则没有权限连接到外网. 方法:控制面板--window防火墙---高 ...

  7. 01-JavaScript介绍

    JavaScript价绍 1.引言 Web前端有三层: HTML:从语义的角度,描述页面结构 CSS:从审美的角度,描述样式(美化页面) JavaScript:从交互的角度,描述行为(提升用户体验) ...

  8. java异常Exception

    学习笔记: 一.程序的异常:Throwable 严重问题:Error ,我们不处理.这种问题一般很严重,不如内存溢出 问题:Exception 编译问题:不是RuntimeException异常.必须 ...

  9. 【学习总结】Git学习-参考廖雪峰老师教程七-标签管理

    学习总结之Git学习-总 目录: 一.Git简介 二.安装Git 三.创建版本库 四.时光机穿梭 五.远程仓库 六.分支管理 七.标签管理 八.使用GitHub 九.使用码云 十.自定义Git 期末总 ...

  10. html,css学习实践总结

    网页的布局方式 1.什么是网页的布局方式? 网页的布局方式其实就是指浏览器是如何对网页中的元素进行排版的 1.标准流(文档流/普通流)排版方式 1.1其实浏览器默认的排版方式就是标准流的排版方式 1. ...