Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.HashSet;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- int m = scan.nextInt();
- HashSet<Integer> set = new HashSet<Integer>();
- int[][] arr = new int[n][m];
- String s = scan.nextLine();//перевод строки надо считать
- for (int i = 0; i < n; i++) {
- s = scan.nextLine();
- for (int j = 0; j < m; j++) {
- arr[i][j] = (int)(s.charAt(j) - '0');
- }
- }
- for (int i = 0; i < m; i++) {
- int max = 0;
- for (int j = 0; j < n; j++) {
- if (arr[j][i] >= max) {
- max = arr[j][i];
- }
- }
- for (int j = 0; j < n; j++) {
- if (arr[j][i] == max) {
- set.add(j);
- }
- }
- }
- System.out.print(set.size());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement