Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Assignment 1 Dinner with Emma Input: File Input Output: Standard Output Jack decides to invite Emma out for a dinner. Jack is a modest

Programming Assignment 1
Dinner with Emma
Input: File Input Output: Standard Output
Jack decides to invite Emma out for a dinner. Jack is a modest student, and he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, and 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 make their choice optimally: Emma wants to maximize the cost of the dinner, and 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 File
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 Tests
Inputfile1.txt
34 4135 2222 5451
Output
2
inputfile2.txt
33 123 231 312
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.
Resources
sample-input.txt
output1.txt
Relevant API:
o FileInputStream
o FileNotFoundException o IOException
o Scanner o System
Discussion
If they decide to change the way to let Jack to choose the avenue first, what will happen? In detail, firstly Jack chooses the avenue to dinner and then Emma chooses the street. Emma and Jack make their choice optimally: Emma wants to maximize the cost of the dinner, and Jack wants to minimize it.Jack takes into account that Emma wants to maximize the cost of the dinner. Find the cost of the dinner for the couple in love. Would you get the same answer as the previous selection? Why? If you can correctly implement it and correctly answer the question, you will get extra credit for this project.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions