zoukankan      html  css  js  c++  java
  • POJ 2379

    #include <iostream>
    #include <algorithm>
    #define MAXN 1005
    using namespace std;
    
    struct node
    {
        bool p[21];
        int sum;
        int pre_sum[21];
        int num_pro;
        int team;
    };
    
    node _m[MAXN];
    
    struct node_1
    {
        int k[4];
    };
    
    node_1 in[MAXN];
    
    int test;
    int num;
    bool op(node a,node b);
    
    void init();
    bool op_1(node_1 a,node_1 b);
    int main()
    {
        int i;
        int j;
        int team;
        int pro;
        int time;
        int res;
        //freopen("acm.acm","r",stdin);
        cin>>num>>test;
        for(i = 0; i < test; ++ i)
        {
            for(j = 0; j < 4; ++ j)
            {
                cin>>in[i].k[j];
            }
        }
    
        sort(in,in+test,op_1);
    
        init();
        
        for(i = 0; i < test; ++ i)
        {
            team = in[i].k[0];
            pro = in[i].k[1];
            time = in[i].k[2];
            res = in[i].k[3];
            if(_m[team].p[pro] == false)
            {
                if(res == 0)
                {
                    _m[team].pre_sum[pro] += 1200;
                }
                else
                {
                    _m[team].sum += time;
                    _m[team].sum += _m[team].pre_sum[pro];
                    ++ _m[team].num_pro;
                    _m[team].p[pro] = true;
                }
            }
        }
        sort(_m+1,_m+num+1,op);
        for(i = 1; i < num; ++ i)
        {
            cout<<_m[i].team<<" ";
        }
        cout<<_m[i].team;
    }
    
    bool op_1(node_1 a,node_1 b)
    {
        if(a.k[2] < b.k[2])
            return true;
        return false;
    }
    
    bool op(node a,node b)
    {
        if(a.num_pro > b.num_pro)
        {
            return true;
        }
        else if(a.num_pro == b.num_pro)
        {
            if(a.sum < b.sum)
                return true;
            else if(a.sum == b.sum)
            {
                if(a.team < b.team)
                    return true;
                else 
                    return false;
            }
            else 
                return false;
        }
        else
            return false;
    }
    
    void init()
    {
        int i;
        int j;
        for(i = 1; i <= num; ++ i)
        {
            for(j = 1; j < 21; ++ j)
            {
                _m[i].p[j] = false;
                _m[i].pre_sum[j] = 0;
            }
            _m[i].team = i;
            _m[i].sum = 0;
            _m[i].num_pro = 0;
        }
    }
  • 相关阅读:
    ps入门
    ls命名 | Linux统计文件夹内的文件个数
    python打包成可执行文件
    装饰器
    poj 2752 Seek the Name, Seek the Fame
    字符串最大值
    次小生成树
    Selecting Courses
    poj 3461 Oulipo
    poj 2406 Power Strings
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4568384.html
Copyright © 2011-2022 走看看