Created
August 29, 2013 09:11
-
-
Save w00lf/6375899 to your computer and use it in GitHub Desktop.
*********Теория игр*********
http://acmp.ru/index.asp?main=task&id_task=54
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class Main{ | |
public static void main(String[] argv) throws IOException,Exception{ | |
new Main().run(); | |
} | |
PrintWriter pw; | |
public static StreamTokenizer sc ; | |
public static int nextInt() throws Exception{ | |
sc.nextToken(); | |
return (int)sc.nval; | |
} | |
public void run() throws IOException,Exception{ | |
sc = new StreamTokenizer(new BufferedReader(new FileReader("input.txt"))); | |
int n = nextInt(); | |
int m = nextInt(); | |
int[] maximum_columns = new int[m]; | |
int[] minimums_rows = new int[n]; | |
Arrays.fill(maximum_columns, -2100); | |
Arrays.fill(minimums_rows, 2100); | |
int current = 0; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
current = nextInt(); | |
if (current > maximum_columns[j]) { | |
maximum_columns[j] = current; | |
} | |
if (current < minimums_rows[i]) { | |
minimums_rows[i] = current; | |
} | |
} | |
} | |
current = minimums_rows[0]; | |
pw = new PrintWriter(new File("output.txt")); | |
for (int i = 0; i < minimums_rows.length; i++) { | |
if (minimums_rows[i] > current) { | |
current = minimums_rows[i]; | |
} | |
} | |
pw.print(current + " "); | |
current = maximum_columns[0]; | |
for (int i = 0; i < maximum_columns.length; i++) { | |
if (maximum_columns[i] < current) { | |
current = maximum_columns[i]; | |
} | |
} | |
pw.print(current); | |
pw.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment