B. Dinner with Emma

题目连接:

http://www.codeforces.com/contest/616/problem/A

Description

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.

Sample Input

3 4

4 1 3 5

2 2 2 2

5 4 5 1

Sample Output

2

Hint

题意

给你n行m列,A负责选行,B负责选列,A先选

A希望选择出来的数尽量大,B希望选择出来的数尽量小

问最后答案应该是多少

题解:

输出比较每一行的最小值,然后输出最大的就好了

因为A先选,所以肯定会选择某一行中,最小值最大的那个

B肯定选择这一行的最小值

代码

#include<bits/stdc++.h>
using namespace std; int Ans = 0;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
int T = 1e9;
for(int j=0;j<m;j++)
{
int x;scanf("%d",&x);
T = min(x,T);
}
Ans = max(T,Ans);
}
printf("%d\n",Ans);
}

Codeforces Educational Codeforces Round 5 B. Dinner with Emma 暴力的更多相关文章

  1. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  2. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  3. codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers

    题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...

  4. codeforces Educational Codeforces Round 16-E(DP)

    题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...

  5. Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph

    E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...

  6. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  7. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学

    E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...

  9. Codeforces Educational Codeforces Round 5 D. Longest k-Good Segment 尺取法

    D. Longest k-Good Segment 题目连接: http://www.codeforces.com/contest/616/problem/D Description The arra ...

随机推荐

  1. 【转】Linux mount/unmount命令

    转自:http://www.cnblogs.com/xd502djj/p/3809375.html 格式:mount [-参数] [设备名称] [挂载点] 其中常用的参数有:-a 安装在/etc/fs ...

  2. Cocos2d-android (03) 向量

    向量的基本运算及动作 import org.cocos2d.actions.interval.CCJumpBy; import org.cocos2d.actions.interval.CCMoveB ...

  3. 高级正则表达式技术(Python版)

    正则表达式是从信息中搜索特定的模式的一把瑞士军刀.它们是一个巨大的工具库,其中的一些功能经常被忽视或未被充分利用.今天我将向你们展示一些正则表达式的高级用法. 举个例子,这是一个我们可能用来检测电话美 ...

  4. 【重读】The C++ Programming Language/C++编程语言(一)

    最近在写C++系列的文章,翻出以前看过的 C++之父Bjarne Stroustrup的书.再一次,竟然又有新的领悟.现在看来,这不是一本只讲C++的书,对于程序设计/开发,以及如何学习开发知识都有所 ...

  5. 回调函数与DOM事件

    原文:http://dean.edwards.name/weblog/2009/03/callbacks-vs-events/ 先看如下代码: document.addEventListener(&q ...

  6. Ubuntu 上安装R

    1. 编辑 /etc/apt/sources.listsudo cp /etc/apt/sources.list /etc/apt/sources.list.backupsudo gedit sour ...

  7. Samsung Galaxy S II GT-I9100 指令全集 部分指令请慎用

    英文版 谷歌翻译 Obtain/Change Device Information *#06# (Display IMEI number) *#1234# (Display current firmw ...

  8. printf输出字符串的一些格式

    1. 原样输出字符串:    printf("%s", str); 2. 输出指定长度的字符串, 超长时不截断, 不足时右对齐:    printf("%Ns" ...

  9. C++拓扑排序

    安利一篇比较写的比较好的的博客... 拓扑排序的原理及其实现 我本来以为我看懂了原理就会打了,没想到因为没有手动实践过...原理实际上也没记清楚.... 一题HDU的拓扑裸题HDU 3342 我的拓扑 ...

  10. Codeforces 588E. A Simple Task (线段树+计数排序思想)

    题目链接:http://codeforces.com/contest/558/problem/E 题意:有一串字符串,有两个操作:1操作是将l到r的字符串升序排序,0操作是降序排序. 题解:建立26棵 ...