Educational Codeforces Round 5 B. Dinner with Emma
来源:互联网 发布:java获取自己程序路径 编辑:程序博客网 时间:2024/04/30 08:06
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 from1 to n and the avenues are numbered with integers from1 to m. The cost of dinner in the restaurant at the intersection of thei-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 thej-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 dinner1. So she chooses the second street and Jack chooses any avenue. The cost of the dinner is2.
In the second example regardless of Emma's choice Jack can choose a restaurant with the cost of the dinner1.
题意:两个人去吃饭,一个人要尽可能多花钱,一个人尽可能少花钱,一个决定行,一个决定列,然后确定一个餐厅
思路:直接取每行的最小值然后取最小值中的最大值
ac代码:
#include<stdio.h>#include<math.h>#include<string.h>#include<stack>#include<queue>#include<vector>#include<iostream>#include<algorithm>#define MAXN 1001000#define LL long long#define ll __int64#define INF 0x7fffffff#define mem(x) memset(x,0,sizeof(x))#define PI acos(-1)#define mod 1000000007using namespace std;int main(){int i,n,m,j;ll a;while(scanf("%d%d",&n,&m)!=EOF){ll ma=-INF;for(i=0;i<n;i++){ll mi=INF;for(j=0;j<m;j++){scanf("%I64d",&a);mi=min(mi,a);}ma=max(ma,mi);}printf("%I64d\n",ma);}return 0;}
- Educational Codeforces Round 5 B. Dinner with Emma B. Dinner with Emma
- Educational Codeforces Round 5-B. Dinner with Emma(贪心)
- Educational Codeforces Round 5 B. Dinner with Emma
- 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 (模拟)水
- CF Dinner with Emma 616B
- Educational Codeforces Round 5 B
- codeforces_616B. Dinner with Emma
- Educational Codeforces Round 5(B)贪心
- Educational Codeforces Round 3 B
- Educational Codeforces Round 20 B
- Educational Codeforces Round 23 B
- Educational Codeforces Round 26 B
- Codeforces Educational Round 5
- 获取视频的第一帧缩略图(本地视频、网络视频)
- java网络编程
- java中Keytool的使用总结
- Dynamics CRM Plugin DLL恢复工具
- 笨办法学Python学习笔记 练习17
- Educational Codeforces Round 5 B. Dinner with Emma
- 如何用 React Native 创建一个iOS APP?(二)
- Android Gradle Plugin指南(一)
- tcpdump捕包乱序的解决方案
- ios 基础攻略
- 相较于其他语言,golang的突出特点和优势
- live555学习笔记2-基础类
- HDU 1005 Number Sequence
- CC2540关于定时器模模模式的设置