Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- int m = in.nextInt();
- int flag = 0;
- int[][] matrix = new int[n][m];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- matrix[i][j] = in.nextInt();
- }
- }
- int k = in.nextInt();
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (flag != 1) {
- if (matrix[i][j] == 0) {
- int chislo = 0;
- for (int z = j; z < m; z++) {
- if (matrix[i][z] == 0) {
- chislo++;
- } else {
- break;
- }
- }
- if (chislo == k) {
- flag = 1;
- System.out.print(i + 1);
- break;
- }
- }
- }
- }
- }
- if (flag == 0) {
- System.out.print(0);
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement