A. Marks

來源:互聯網
上載者:User
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

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.

Output

Print the single number — the number of successful students in the given group.

Sample test(s)input
3 3223232112
output
2
input
3 5917281182811111
output
3
Note

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;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.