CodeForces 616B Dinner with Emma
来源:互联网 发布:阿里云ssh登录 编辑:程序博客网 时间:2024/05/18 03:05
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.
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.
Print the only integer a — the cost of the dinner for Jack and Emma.
3 44 1 3 52 2 2 25 4 5 1
2
3 31 2 32 3 13 1 2
1
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.
恩,他就是选的方式,每行中最小值中的最大值。
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#define maxn 110#define inf 1e9using namespace std;int main(){ int n,m,a; while(~scanf("%d%d",&n,&m)) { int ans=0; for(int i=0;i<n;++i) { int tem=inf; for(int j=0;j<m;++j) { scanf("%d",&a); if(a<tem) tem=a; } if(tem>ans) ans=tem; } printf("%d\n",ans); } return 0;}
- CodeForces 616B Dinner with Emma
- CodeForces 616B Dinner with Emma【水】
- CodeForces 616B Dinner with Emma
- CodeForces 616 B. Dinner with Emma(水~)
- Codeforces--616B--Dinner with Emma(模拟水题)
- CodeForces - 616B Dinner with Emma (模拟)水
- Educational Codeforces Round 5 B. Dinner with Emma B. Dinner with Emma
- CF Dinner with Emma 616B
- Educational Codeforces Round 5-B. Dinner with Emma(贪心)
- Educational Codeforces Round 5 B. Dinner with Emma
- codeforces_616B. Dinner with Emma
- codeforces#290 Fox And Dinner
- codeforces 251B Playing with Permutations 模拟
- CodeForces 8B - Obsession with Robots
- Dinner
- Dinner
- Dinner
- Dinner
- 浅析数据结构中栈与C实现
- C++开发人脸性别识别教程(10)——添加图片的人脸检测程序
- Java类集框架
- Java执行顺序
- 名侦探柯南(贪心问题)
- CodeForces 616B Dinner with Emma
- 实现tableView和collectionView的相互关联方法
- <LeetCode OJ> 141 / 142 Linked List Cycle(I / II)
- 行为型模式-状态模式state
- BeanUtils操作Bean的属性
- 实现应用Matrix旋转图像
- ElasticSearch path.home is not configured报错解决
- Qt程序界面美化一-- stylesheet
- Block和typedef