HDOJ 2022 海选女主角

来源:互联网 发布:python re文本 编辑:程序博客网 时间:2024/05/17 09:14

        遍历所有MM,记录绝对值分数最高的即可。

#include <cstdio>//#define YANGYUANint main(){#ifdef YANGYUAN    freopen("in.txt", "r", stdin);#endif // YANGYUAN    int m, n;    while (scanf("%d%d", &m, &n) != EOF){        int score, max, row, col;for (int i = 1; i <= m; i++)// 对应行{int j = 1;            if (1 == i){                scanf("%d", &max);// 获取第一个mm,并暂定其分数最高                j = 2;// 因为第一个mm分数已经获得所以从第二列开始                row = col = 1;// 获取mm的位置}for (; j <= n; j++)// 对应列{scanf("%d", &score);                if ((max < 0 ? -max : max) < (score < 0 ? -score : score))// 比较分数的绝对值大小{max = score;                    row = i;                    col = j;}}}        printf("%d %d %d\n", row, col, max);}    return 0;}


原创粉丝点击