Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has n students. They received marks for m subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at some subject, if there is no student who got a higher mark for this subject. Let's consider a student successful, if there exists a subject he is the best at.
Your task is to find the number of successful students in the group.
The first input line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of students and the number of subjects, correspondingly. Next n lines each containing m characters describe the gradebook. Each character in the gradebook is a number from 1 to 9. Note that the marks in a rows are not sepatated by spaces.
Print the single number — the number of successful students in the given group.
3 3 223 232 112
2
3 5 91728 11828 11111
3
In the first sample test the student number 1 is the best at subjects 1 and 3, student 2 is the best at subjects 1 and 2, but student 3 isn't the best at any subject.
In the second sample test each student is the best at at least one subject.
解题说明:此题就是判断一列数中最大的数字的个数
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
int n,m;
char a[101][102];
int b[101];
int max;
int count;
int i,j;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
{
b[i]=0;
}
for(i=0;i<n;i++)
{
scanf("%s",&a[i]);
}
for(j=0;j<m;j++)
{
max=a[0][j]-'0';
for(i=0;i<n;i++)
{
if(a[i][j]-'0'>max)
{
max=a[i][j]-'0';
}
}
for(i=0;i<n;i++)
{
if(a[i][j]-'0'==max)
{
b[i]=1;
}
}
}
count=0;
for(i=0;i<n;i++)
{
if(b[i]==1)
{
count++;
}
}
printf("%d\n",count);
return 0;
}