A. Marks
来源:互联网 发布:miss淘宝店外设店 编辑:程序博客网 时间:2024/06/05 11:17
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 studentsuccessful, 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 from1 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 3223232112
2
3 5917281182811111
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<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define MAXN 102
using namespace std;
char score[MAXN][MAXN];
int stu[MAXN] = {0};
int main()
{
int n, m, Max;
scanf("%d %d", &n, &m);
for(int i = 0; i < n; ++i)
{
scanf("%s", &score[i]);
}
for(int j = 0; j < m; ++j)
{
Max = score[0][j] - '0';
for(int i = 0; i < n; ++i)
{
if(score[i][j] - '0' > Max)
{
Max = score[i][j] - '0';
}
}
for(int i = 0; i < n; ++i)
{
if(score[i][j] - '0' == Max)
{
stu[i] = 1;
}
}
}
int count=0;
for(int i = 0; i < n; ++i)
{
if(stu[i] == 1)
{
count++;
}
}
printf("%d\n", count);
return 0;
}
- A. Marks
- A. Marks
- marks
- Marks
- Marks Distribution
- 【marks】testing
- 【marks】mongodb
- 【marks】Unity3D
- Easy Marks
- Jury Marks
- Nothing but for marks
- spoj 839 Opitmal marks
- spoj 839(Optimal Marks)
- spoj839(Optimal Marks)
- spoj 839 Optimal Marks
- SPOJ 839 Optimal Marks
- Uva-10910-Marks Distribution
- UVA 10910 Marks Distribution
- 设计模式之观察者1
- [kaggle竞赛实践] Titanic幸存预测问题--logistic回归解决方案
- Storm问题——组件带参数构造函数未被调用,抛出NullpointerException
- 矩阵线性无关的特征向量个数与矩阵的秩的关系
- 复数
- A. Marks
- 算法学习 - 链表之归并排序_O(1)空间_O(NlogN)时间_C++
- LINUX修改IP地址
- XML的简单读取与写入
- php xhprof 扩展的使用
- linux中pip安装步骤与使用详解
- java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostExce
- PreferenceActivity里自定义标题栏(title bar)出错:requestFeature() must be called before ad
- VB批处理后重定向输出