zoukankan      html  css  js  c++  java
  • poj2379

    简单题

    题意:对于一场acm比赛,给出所有提交状况,求排名。注意:提交状况并非按时间顺序。

    View Code
    #include <iostream>
    #include
    <cstdio>
    #include
    <cstdlib>
    #include
    <cstring>
    #include
    <algorithm>
    using namespace std;

    #define maxn 1005
    #define maxp 25

    struct Team
    {
    int t, p, id;
    }team[maxn];

    struct Sub
    {
    int a, b, c, d;
    }sub[maxn];

    int n, m;
    bool solved[maxn][maxp];
    int reject[maxn][maxp];

    bool operator < (const Team &a, const Team &b)
    {
    if (a.p != b.p)
    return a.p > b.p;
    if (a.t != b.t)
    return a.t < b.t;
    return a.id < b.id;
    }

    bool operator < (const Sub &a, const Sub &b)
    {
    return a.c < b.c;
    }

    int main()
    {
    //freopen("t.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    memset(solved,
    0, sizeof(solved));
    memset(reject,
    0, sizeof(reject));
    memset(team,
    0, sizeof(team));
    for (int i = 1; i <= n; i++)
    team[i].id
    = i;
    for (int i = 0; i < m; i++)
    scanf(
    "%d%d%d%d", &sub[i].a, &sub[i].b, &sub[i].c, &sub[i].d);
    sort(sub, sub
    + m);
    for (int i = 0; i < m; i++)
    {
    int a, b, c, d;
    a
    = sub[i].a;
    b
    = sub[i].b;
    c
    = sub[i].c;
    d
    = sub[i].d;
    if (solved[a][b])
    continue;
    if (d)
    {
    solved[a][b]
    = true;
    team[a].t
    += c + reject[a][b] * 20 * 60;
    team[a].p
    ++;
    }
    else
    reject[a][b]
    ++;
    }
    sort(team
    + 1, team + n + 1);
    printf(
    "%d", team[1].id);
    for (int i = 2; i <= n; i++)
    printf(
    " %d", team[i].id);
    putchar(
    '\n');
    return 0;
    }
  • 相关阅读:
    面向对象之property
    mysql数据库基本操作
    mysql数据库操作
    初识多线程__上
    npm 安装express npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
    markdown快捷键
    try_except__异常处理
    妹子图爬取__RE__BS4
    进程中的锁以及进程池
    pip升级到18.0版本过程中报错解决方法
  • 原文地址:https://www.cnblogs.com/rainydays/p/2115574.html
Copyright © 2011-2022 走看看