Advertisement
shek_shek

TEMP

Oct 19th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.HashSet;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         int n = scan.nextInt();
  10.         int m = scan.nextInt();
  11.  
  12.         HashSet<Integer> set = new HashSet<Integer>();
  13.         int[][] arr = new int[n][m];
  14.         String s = scan.nextLine();//перевод строки надо считать
  15.         for (int i = 0; i < n; i++) {
  16.             s = scan.nextLine();
  17.             for (int j = 0; j < m; j++) {
  18.                 arr[i][j] = (int)(s.charAt(j) - '0');
  19.             }
  20.         }
  21.         for (int i = 0; i < m; i++) {
  22.             int max = 0;
  23.             for (int j = 0; j < n; j++) {
  24.                 if (arr[j][i] >= max) {
  25.                     max = arr[j][i];
  26.                 }
  27.             }
  28.             for (int j = 0; j < n; j++) {
  29.                 if (arr[j][i] == max) {
  30.                     set.add(j);
  31.                 }
  32.             }
  33.         }
  34.         System.out.print(set.size());
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement