#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. 在MySQL数据库建立多对多的数据表关系

    在数据库中,如果两个表的之间的关系为,多对多的关系,如:“学生表和课程表”,一个学生的可以选多门课,一门课也可以被多门学习选;根据数据库的设计原则,应当形成第三张关联表 步骤1:创建三张数据表Stud ...

  2. 数独破解c++代码

    数独破解c++代码 #include <iostream> #include <cstring> #include <cstdio> #include <st ...

  3. Generator & yield write in sync way

    Generator & yield write in sync way var p = new Promise(function(resolve, reject){ setTimeout(fu ...

  4. rabbitmq问题之HTTP access denied: user 'guest' - User can only log in via localhost

    问题: 昨天安装rabbitmq(3.3.4版本)服务,并启用rabbitmq_management插件去管理rabbitmq服务,但是在访问管理界面使用guest用户登录时出现login faile ...

  5. jQuery插入节点的方法

    注:摘自<锋利的jQuery(第二版)> append() 向每个匹配的元素内部追加内容:  HTML代码:<p>我想说:</p>jQuery代码:$(" ...

  6. 关于Program Size

    Program Size: Code=86496 RO-data=9064 RW-data=1452 ZI-data=16116 Code是代码占用的空间,RO-data是 Read Only 只读常 ...

  7. ListFragment和ListActivity的setOnItemClickListener不起作用

    在使用ListFragment时,发现一个奇怪的问题,就是getListView().setOnItemClickListener(new OnItemClickListener...)不起作用.在s ...

  8. Unix/Linux环境C编程入门教程(18) kali-linuxCCPP开发环境搭建

    1. Kali linux是BT5的晋级版本,用于信息安全.基于Debian7内核.新建虚拟机. 2. 选择默认虚拟机 3. 选择稍后安装操作系统 4.选择Linux Debian7 64位,因为Ka ...

  9. JQuery(下)

    26.jQuery 中的 DOM 操作 )DOM(Document Object Model—文档对象模型):一种与浏览器, 平台, 语言无关的接口, 使用该接口可以轻松地访问页面中所有的标准组件 ) ...

  10. 在asp.net中如何实现伪静态页 [转]

    我在这里就不过多讨论静态页.伪静态页.动态页的长短利弊了.只是单纯的讲解如何在asp.net中如何实现伪静态页,以帮助有这方面有需求的朋友,快速解决boss派下来的任务.(拿奖金的时候,记得有我一份功 ...