Created
April 22, 2015 17:52
-
-
Save TPAKC/af294158166e4c793e79 to your computer and use it in GitHub Desktop.
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.util.Scanner; | |
public class noob { | |
static int max; | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int n = in.nextInt(),m = in.nextInt(); | |
int[][] a = new int[n][m]; | |
for (int i = 0; i < n; i++) | |
for (int j = 0; j < m; j++) a[i][j] = in.nextInt(); | |
int i = n - 1; | |
int j = m - 1; | |
while (i > 0) a[i - 1][j] += a[i--][j]; | |
while (j > 0) a[n - 1][j - 1] += a[n - 1][j--]; | |
for (i = n - 2; i >= 0; i--) | |
for (j = m - 2; j >= 0; j--) a[i][j] += max(a[i][j + 1], a[i + 1][j + 1], a[i + 1][j]); | |
System.out.println((a[0][0] > 0 ? "winner" : "loser") + "\n" + a[0][0]); | |
} | |
static int max(int a, int b, int c) { | |
if (a > b) max = a; | |
else max = b; | |
if (c > max) max = c; | |
return max; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment