#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <stack>
#define N 400
#define ll int
using namespace std;
struct node{
 ll gold,all,pre,num;
 double pa,pg;
 ll r1,r2,r3,r4;
 
}p[N];
bool cmp1(node a,node b){return a.gold>b.gold;}
bool cmp2(node a,node b){return a.all>b.all;}
bool cmp3(node a,node b){return a.pa>b.pa;}
bool cmp5(node a,node b){return a.pg>b.pg;}

bool cmp4(node a,node b){return a.num<b.num;}

int main(){
 ll n,m,i,j;
 while(~scanf("%d%d",&n,&m)){
  for(i=0;i<n;i++){
   scanf("%d %d %d",&p[i].gold,&p[i].all,&p[i].pre);
   p[i].num=i;
   
   if(p[i].pre==0){p[i].pg=p[i].pa=1000;continue;}
   if(p[i].all)
    p[i].pa=(double)p[i].all/(double)p[i].pre;
   else p[i].pg=0;
   if(p[i].gold)
    p[i].pg=(double)p[i].gold/(double)p[i].pre;
   else p[i].pg=0;
  }
  sort(p,p+n,cmp1);
  ll rank=0,ranktemp=0;
  for(i=0;i<n;i++)
   if(i!=0 && p[i].gold==p[i-1].gold)
    p[i].r1=rank,ranktemp++;
   else
   {
    rank+=ranktemp+1;
    ranktemp=0;
    p[i].r1=rank;
   }
   
   sort(p,p+n,cmp2);
   rank=0,ranktemp=0;
   for(i=0;i<n;i++)
    if(i!=0 && p[i].all==p[i-1].all)
     p[i].r2=rank,ranktemp++;
    else
    {
     rank+=ranktemp+1;
     ranktemp=0;
     p[i].r2=rank;
    }
    sort(p,p+n,cmp5);
    rank=0,ranktemp=0;
    for(i=0;i<n;i++)
     if(i!=0 && p[i].pg==p[i-1].pg)
      p[i].r4=rank,ranktemp++;
     else
     {
      rank+=ranktemp+1;
      ranktemp=0;
      p[i].r4=rank;
     }
     sort(p,p+n,cmp3);
     rank=0,ranktemp=0;
     for(i=0;i<n;i++)
      if(i!=0 && p[i].pa==p[i-1].pa)
       p[i].r3=rank,ranktemp++;
      else
      {
       rank+=ranktemp+1;
       ranktemp=0;
       p[i].r3=rank;
      }
      sort(p,p+n,cmp4);
      
      while(m--){
       scanf("%d",&i);
       ll a=N,b;
       if(p[i].r1<a){a=p[i].r1;b=1;}
       if(p[i].r2<a){a=p[i].r2;b=2;}
       if(p[i].r4<a){a=p[i].r4;b=3;}
       if(p[i].r3<a){a=p[i].r3;b=4;}
       printf("%d:%d",a,b);
       if(m)printf(" ");
       else printf("\n");
      }
 }
 return 0;
}
/*
4 4
51 100 1000
36 110 300
6 14 32
5 18 40
0 1 2 3

7 2
51 100 1000
36 110 300
6 14 32
5 18 40
23 73 142
19 47 61
16 41 82
4 6
6 6
15 45 50
45 90 500
50 100 1000
30 80 75
50 100 500
40 90 100
2 4 1 5 3 0
4 4
2 3 1
1 3 1
2 5 1
0 4 1
1 3 2 0
*/

浙大PAT 7-06 题解的更多相关文章

  1. 浙大pat 1035题解

    1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...

  2. 浙大pat 1025题解

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  3. 浙大pat 1011题解

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  4. 浙大pat 1012题解

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  5. 浙大 pat 1003 题解

    1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...

  6. 浙大 pat 1038 题解

    1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  7. 浙大 pat 1047题解

    1047. Student List for Course (25) 时间限制 400 ms 内存限制 64000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...

  8. 浙大pat 1054 题解

    1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...

  9. 浙大pat 1059 题解

    1059. Prime Factors (25) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...

随机推荐

  1. vb 6.0 msflexgrid 用法详解

    问题一 msflexgrid 根据行数或列数的大小,滚动条的滚动块长度怎么改变,发现滚动条很不好用,很小

  2. Linq to sql 操作

    1.往数据库添加数据 NorthwindDataContext abc = new NorthwindDataContext(); abc.Log = Console.Out; User a = ne ...

  3. 【Chromium中文文档】OS X 沙箱设计

    OS X 沙箱设计 转载请注明出处:https://ahangchen.gitbooks.io/chromium_doc_zh/content/zh//General_Architecture/OSX ...

  4. Oracle EBS-SQL (PO-5):采购订单控制信息查询.sql

    select distinct pla.po_header_id, --pha.type_lookup_code, pha.segment1       采购订单号, appf.full_name   ...

  5. js自定义类和对象及继承

    1.工厂方式 <script type="text/javascript"> function createObject(name){ var p = new Obje ...

  6. 进程序名得到进程ID和句柄与进程的公司名(使用快照和GetPeFileCompany和VerQueryValueW等函数)

    WORD  GetProcessIdByName(WCHAR *processName){ DWORD processId = 0;HANDLE hProcessSnap=CreateToolhelp ...

  7. php set env

    SYSTEM WARNING: 'date_default_timezone_get(): It is not safe to rely on the system's timezone settin ...

  8. linux安装mongodb并启动

    CentOS6.4 安装MongoDB   1.下载MongoDB(64位) http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tg ...

  9. POJ 1753 Flip Game (DFS + 枚举)

    题目:http://poj.org/problem?id=1753 这个题在開始接触的训练计划的时候做过,当时用的是DFS遍历,其机制就是把每一个棋子翻一遍.然后顺利的过了.所以也就没有深究. 省赛前 ...

  10. spring security执行流程图

    今天看到非常多人转载了这篇文章,这里备注一下.原文来自CSDN我的博客. 近期在研究spring security的配置,研究了一个星期了,在官网看了下.仅仅配置出来了简单的登录,但不知如何从数据库读 ...