• A


    ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:
    Each run is either accepted or rejected.
    The problem is considered solved by the team, if one of the runs submitted for it is accepted.
    The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submission of the first accepted run for this problem (in minutes) plus 20 minutes for every other run for this problem before the accepted one. For an unsolved problem consumed time is not computed.
    The total time is the sum of the time consumed for each problem solved.
    Teams are ranked according to the number of solved problems. Teams that solve the same number of problems are ranked by the least total time.
    While the time shown is in minutes, the actual time is measured to the precision of 1 second, and the the seconds are taken into account when ranking teams.
    Teams with equal rank according to the above rules must be sorted by increasing team number.

    Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.

    Input

    Input contains integer numbers C N, followed by N quartets of integes ci pi ti ri, where ci -- team number, pi -- problem number, ti -- submission time in seconds, ri -- 1, if the run was accepted, 0 otherwise.
    1 ≤ C, N ≤ 1000, 1 ≤ ci ≤ C, 1 ≤ pi ≤ 20, 1 ≤ ti ≤ 36000.

    Output

    Output must contain C integers -- team numbers sorted by rank.

    Sample Input

    3 3
    1 2 3000 0
    1 2 3100 1
    2 1 4200 1

    Sample Output

    2 1 3

    排序,注意输入不是按时间输入的,先储存然后排序,在操作

    #include<iostream>
    #include<stdio.h>
    #include<stdlib.h>
    #include<cmath>
    #include<string.h>
    #include<algorithm>
    #define sf scanf
    #define pf printf
    #define pb push_back
    #define mm(a,b) memset((a),(b),sizeof(a))
    #include<vector>
    typedef long long ll;
    typedef double db;
    const ll mod=1e9+7;
    using namespace std;
    const double pi=acos(-1.0);
    struct q
    {
    	int score[1005];
    	int num;
    	int sum;
    	int temp[1005]; 
    }a[1005];
    struct qq
    {
    	int c,p,t,r;
    }cz[1005]; 
    void solve(int c,int p,int t,int r)
    {
    	if(a[c].temp [p]==0)//如果没过 
    	{
    		if(r)
    		{
    			a[c].temp[p] =1;
    			a[c].num++;
    			a[c].sum+=a[c].score[p]*20*60+t;  
    		}else
    			a[c].score[p]++; //罚时次数加一	
    	}
    }
    void sortt(qq cz[1005],int n)
    {
    	for(int i=0;i<n-1;i++)
    	for(int j=0;j<n-i-1;j++)
    	{
    		if(cz[j].t >cz[j+1].t )
    		{
    			swap(cz[j].c ,cz[j+1].c );
    			swap(cz[j].p ,cz[j+1].p );
    			swap(cz[j].r ,cz[j+1].r );
    			swap(cz[j].t ,cz[j+1].t );
    		}
    	}
    }
    int main()
    {
    	int n,p,pp,c,t,r;
    	sf("%d%d",&n,&pp);
    	for(int i=1;i<=n;i++)
    	{
    		mm(a[i].score ,0);
    		a[i].num =0;
    		a[i].sum =0;
    		mm(a[i].temp ,0);
    	}	
    	for(int i=0;i<pp;i++)//储存操作 
    		sf("%d%d%d%d",&cz[i].c ,&cz[i].p,&cz[i].t,&cz[i].r);
    	sortt(cz,pp);//对操作进行时间排序 
    	for(int i=0;i<pp;i++)//计算rank 
    		solve(cz[i].c,cz[i].p,cz[i].t,cz[i].r);
    	int nod[21];
    	mm(nod,0);
    	for(int i=1;i<=n;i++)//计算ac的题数的队伍数 
    		nod[a[i].num]++;
    	int tot=1;
    	for(int i=20;i>=0;i--)//排序输出 
    	{
    		for(int j=0;j<nod[i];j++)
    		{
    			int max=mod,qq;
    			for(int j=1;j<=n;j++)
    			{
    				if(a[j].num ==i)
    				{
    					if(max>a[j].sum)
    					{
    						max=a[j].sum;
    						qq=j;
    					}
    				}
    			}
    			if(tot==n)
    			{
    				pf("%d",qq);
    			}else
    			{
    				pf("%d ",qq);
    				tot++;
    				a[qq].num =-1;
    			}
    		}
    	}
    	return 0;
    }
    
  • 相关阅读:
    Neural Collaborative Filtering 神经网络协同过滤
    pyspark(一) 常用的转换操作
    HO引擎近况20210315
    LeetCode–前 K 个高频元素
    常用十大算法(七)— 克鲁斯卡尔算法
    常用十大算法(六)— 普里姆算法
    LeetCode–数值的整数次方
    LeetCode–二叉树的层次遍历 II
    常用十大算法(五)— 贪心算法
    LeetCode–二进制中1的个数
  • 原文地址:https://www.cnblogs.com/wzl19981116/p/9373340.html
Copyright © 2020-2023  润新知