大名鼎鼎的“绅士大盗”亚森罗苹又开始作案了,这次他瞄上的是一艘豪华客轮,可是大名鼎鼎的侦探——嘉尼玛也在客轮上,嘉尼玛接到破译的消息后,马上进行搜捕,现有n个嫌疑人,m条信息,每个人对于每条信息都有一个值(0或1)表示是否满足,现在要找一个最像的人。
输入描述 Input Description
第一行n m
n个人 m个特征
第2~n+1行
一行如下
姓名(长度≤30) 1 1 1 0 ……
输出描述 Output Description
一个字符串
样例输入 Sample Input2 2
jim 0 0
luoping 1 1
样例输出 Sample Outputluoping
数据范围及提示 Data Size & Hint见上
n《100 m《100
#include <iostream> #include <cstdio> #include <string.h> using namespace std; int main() { int n,m; char map[101][31]={0}; scanf("%d%d", &n, &m); int i,j; int a,Max=0,sum=0,lap=0; for(i=0;i<n;i++) { sum=0; scanf("%s", map[i]); for(j=0;j<m;j++) { scanf("%d", &a); sum+=a; if(Max<sum) { Max=sum; lap=i; } } } puts(map[lap]); }