#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. php调用java类文件

    最近在折腾php调用java类,网上查阅资料,最终选用JavaBridge,遇到的第一个问题是java_require() 函数引入自定义java打包而成的jar文件,在新版本的JavaBridge中 ...

  2. [转]用Gson来解析Json数据

    转自太阳尚远的博客:http://blog.yeqianfeng.me/2016/03/02/use_gson_to_parse_json/ 在我们实际开发中像Json和XML这两种格式的数据是最常见 ...

  3. C++ Primer第四版 15.9 再谈文本查询 程序实现

    编程过程中发现书本中的示例程序并不完全,某些地方存在错误,现已改正并添加少许注释.. 1 #include<iostream> 2 #include<fstream> #inc ...

  4. 这些年,我收集的JavaScript代码(一)

    一.取URL中的参数 function getParameterByName(name) { var match = RegExp('[?&]' + name + '=([^&]*)' ...

  5. Web学习

    http://book.2cto.com/201309/31936.html http://alvinalexander.com/ 查看锁表进程SQL语句1: select sess.sid,     ...

  6. 谷歌page speed 安装使用及页面问题详解

    原文地址:http://wenku.baidu.com/view/b0a61f3ebcd126fff7050b40.html 谷歌page speed 安装使用及页面问题详解 谷歌page speed ...

  7. 普林斯顿大学算法课 Algorithm Part I Week 3 排序算法复杂度 Sorting Complexity

    计算复杂度(Computational complexity):用于研究解决特定问题X的算法效率的框架 计算模型(Model of computation):可允许的操作(Allowable oper ...

  8. Linux学习之第十九、条件判断

    原文地址:http://vbird.dic.ksu.edu.tw/linux_basic/0340bashshell-scripts_4.php 条件判断式 只要讲到『程序』的话,那么条件判断式,亦即 ...

  9. php解决与处理网站高并发 大流量访问的方法

    方法/步骤   首先,确认服务器硬件是否足够支持当前的流量 普通的P4服务器一般最多能支持每天10万独立IP,如果访问量比这个还要大, 那么必须首先配置一台更高性能的专用服务器才能解决问题 ,否则怎么 ...

  10. 怎样调通微信支付及微信发货通知接口(Js API)

    怎样调通微信支付及微信发货通知接口(Js API) 微信支付提供了一个支付測试页面,微信支付正式使用须要測通支付.发货通知接口 .告警接口.维权接口.告警接口.维权接口非常easy.支付界面调通也相对 ...