• POJ 2153


      1 #include <iostream>
      2 #include <string>
      3 #include <algorithm>
      4 #define MAXN 10005
      5 using namespace std;
      6 
      7 struct node
      8 {
      9     string name;
     10     int score;
     11     node()
     12     {
     13         score = 0;
     14     }
     15 };
     16 node _m[MAXN];
     17 
     18 bool op_1(node a,node b);
     19 
     20 bool op(node a,node b);
     21 
     22 int Binarry_search(node a[],int size,string num);
     23 
     24 int main()
     25 {
     26     //freopen("acm.acm","r",stdin);
     27     int n;
     28     int m;
     29     string s_tem;
     30     int i;
     31     int j;
     32     int tem;
     33     int place;
     34     cin>>n;
     35     getchar();
     36 
     37     for(i = 0; i < n; ++ i)
     38     {
     39         getline(cin,s_tem);
     40         _m[i].name = s_tem;
     41     }
     42     cin>>m;
     43     sort(_m,_m+n,op_1);
     44     for(i = 0; i < m; ++ i)
     45     {
     46         for(j = 0; j < n; ++ j)
     47         {
     48             scanf("%d",&tem);
     49             getchar();
     50             getline(cin,s_tem);
     51             place = Binarry_search(_m,n,s_tem);
     52             _m[place].score += tem;
     53         }
     54         s_tem = "Li Ming";
     55         place = Binarry_search(_m,n,s_tem);
     56         int ans = 0;
     57         for(j = 0; j < n; ++ j)
     58         {
     59             if(_m[j].score > _m[place].score)
     60             {
     61                 ++ ans;
     62             }
     63         }
     64         cout<<ans+1<<endl;
     65     }
     66 
     67 
     68 }
     69 
     70 bool op_1(node a,node b)
     71 {
     72     if(a.name < b.name)
     73         return true;
     74     return false;
     75 }
     76 
     77 bool op(node a,node b)
     78 {
     79     if(a.score > b.score)
     80     {
     81         return true;
     82     }
     83     else if(a.score == b.score)
     84     {
     85         if(a.name == "Li Ming")
     86         {
     87             return true;
     88         }
     89         //return false;
     90     }
     91     return false;
     92 }
     93 
     94 
     95 ////////////////////////////////////////////////////////////////////////////////////////
     96 int Binarry_search(node a[],int size,string num)
     97 {
     98     int i;
     99     int low = 0;
    100     int high = size -1;
    101     int mid;
    102     while(low <= high)
    103     {
    104         mid = (low + high)/2;
    105         if(num < a[mid].name)
    106         {
    107             high = mid - 1;
    108         }
    109         else if(num > a[mid].name)
    110         {
    111             low = mid + 1;
    112         }
    113         else 
    114             return mid;
    115     }    
    116 //    return false;
    117 }

    关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

    技术网站地址: vmfor.com

  • 相关阅读:
    再谈H2的MVStore与MVMap
    log4j动态日志级别调整
    wireshark抓文件上传的包的结果记录
    struts2对properties资源的处理
    Spring core resourc层结构体系及JDK与Spring对classpath中资源的获取方式及结果对比
    [工具使用] visualvm 通过jmx不能连接
    oracle 安装 启动listener 建库相关
    vscode
    XSSFWorkbook
    TearmQuery()
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4566685.html
Copyright © 2020-2023  润新知