HDU 2022 海选女主角

来源:互联网 发布:淘宝微淘首页在哪里 编辑:程序博客网 时间:2024/04/20 02:13

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2022

这题其实是跟小明调查统计是一个性质的,只是多加了一个绝对值,不懂的可以去看小明调查统计(二)。直接水过。

代码:

#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;struct hx{    int fs;    int hh;    int lh;}w[10001];bool comp(hx x,hx y){    if(abs(x.fs)>abs(y.fs)) return true;    if(abs(x.fs)==abs(y.fs)&&x.hh<y.hh) return true;    if(abs(x.fs)==abs(y.fs)&&x.hh==y.hh&&x.lh<y.lh) return true;    return false;}int main(){    int n,m,i,j,count,cj;    while(~scanf("%d %d",&n,&m))    {        count=0;        for(i=1;i<=n;i++)        {            for(j=1;j<=m;j++)            {                scanf("%d",&cj);                w[count].hh=i;                w[count].lh=j;                w[count].fs=cj;                count++;            }        }        sort(w,w+count,comp);        printf("%d %d %d\n",w[0].hh,w[0].lh,w[0].fs);    }    return 0;}



原创粉丝点击