Google is one of the most famous Internet search engines which hosts and develops a number of Internetbased services and products. On its search engine website, an interesting button ‘I’m feeling lucky’ attracts our eyes. This feature could allow the user skip the search result page and goes directly to the first ranked page. Amazing! It saves a lot of time.
    The question is, when one types some keywords and presses ‘I’m feeling lucky’ button, which web page will appear? Google does a lot and comes up with excellent approaches to deal with it. In this simplified problem, let us just consider that Google assigns every web page an integer-valued relevance. The most related page will be chosen. If there is a tie, all the pages with the highest relevance are possible to be chosen.
    Your task is simple, given 10 web pages and their relevance. Just pick out all the possible candidates which will be served to the user when ‘I’m feeling lucky’.
Input
The input contains multiple test cases. The number of test cases T is in the first line of the input file.
    For each test case, there are 10 lines, describing the web page and the relevance. Each line contains a character string without any blank characters denoting the URL of this web page and an integer Vi denoting the relevance of this web page. The length of the URL is between 1 and 100 inclusively. (1 ≤ Vi ≤ 100)
Output
For each test case, output several lines which are the URLs of the web pages which are possible to be chosen. The order of the URLs is the same as the input. Please look at the sample output for further information of output format.
Sample Input
2
www.youtube.com 1
www.google.com 2
www.google.com.hk 3
www.alibaba.com 10
www.taobao.com 5
www.bad.com 10
www.good.com 7
www.fudan.edu.cn 8
www.university.edu.cn 9
acm.university.edu.cn 10
www.youtube.com 1
www.google.com 2
www.google.com.hk 3
www.alibaba.com 11
www.taobao.com 5
www.bad.com 10
www.good.com 7
www.fudan.edu.cn 8
acm.university.edu.cn 9
acm.university.edu.cn 10
Sample Output
Case #1:
www.alibaba.com
www.bad.com
acm.university.edu.cn
Case #2:
www.alibaba.com

问题链接:UVA12015 Google is Feeling Lucky
问题简述:(略)
问题分析
    给定若干组每组10个的数据,每组数据中包括网页网址和相关数量,计算输出相关数量最多的网页网址(可能有多个)。
    排序求最值问题。
程序说明
    使用常量N,是基于程序通用性的考虑。
    因为需要输出最多相关数量的所有网页(多个),原始数据还是存储在结构数组中比较便于处理。
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA12015 Google is Feeling Lucky */#include <bits/stdc++.h>using namespace std;const int N = 10;
struct Web {string name;int time;
} w[N];bool cmp(Web a, Web b)
{return a.time > b.time;
}int main()
{int t;cin >> t;for(int k = 1; k <= t; k++) {for(int i = 0; i < N; i++)cin >> w[i].name >> w[i].time;sort(w, w + N, cmp);cout << "Case #" << k <<":" << endl;for(int i = 0; w[i].time == w[0].time; i++)cout << w[i].name << endl;}return 0;
}

UVA12015 Google is Feeling Lucky【最值+排序】相关推荐

  1. python字典相同key的值怎么分别取出_python字典值排序并取出前n个key值的方法

    python字典值排序并取出前n个key值的方法 今天在写一个算法的过程中,得到了一个类似下面的字典: {'user1':0.456,'user2':0.999,'user3':0.789,user: ...

  2. Python 字典创建、更新、按键值排序、取最大键值对等操作

    1. 字典创建 In [1]: d = {}In [2]: d Out[2]: {}In [3]: d = dict()In [4]: d Out[4]: {}In [5]: dict(a=1,b=2 ...

  3. 根据数组中对象的属性值排序倒叙

    数组中对象的属性值排序倒叙demo function compare(e) {return function (a, b) {var value1 = a[e];var value2 = b[e];r ...

  4. 用中值排序基数法实现树状结构 (转)

    在BBS的编写中,经常有人问怎样实现树状结构?一个比较不负责任的回答是:使用递归算法.当然,递归是一个可行的办法 (二叉树的历遍也好象只能使用递归算法),但对于BBS来说,这样做势必要进行大量的Sql ...

  5. pandas对dataframe进行排序:单数据列排序、多数据列排序、NA值排序位置、排序算法

    pandas对dataframe进行排序:单数据列排序.多数据列排序.NA值排序位置.排序算法 目录 pandas对dataframe进行排序 #仿真数据 #基于单数据列进行dataframe排序

  6. python中字典按键或键值排序

    字典排序 在程序中使用字典进行数据信息统计时,由于字典是无序的所以打印字典时内容也是无序的.因此,为了使统计得到的结果更方便查看需要进行排序.Python中字典的排序分为按"键"排 ...

  7. python dataframe取列名_python – 获取列名在DataFrame中按其值排序

    我有一个庞大的数据框,我想创建一个字典.字典的键将是行的索引,值将是按该行中的值(降序)排序的数据帧的列名列表.考虑以下示例: df= 23 45 12 3 6 45 0.2 1 0.12 0.5 0 ...

  8. oracle根据null排序,oracle 关于null值排序

    在oracle中根据字段来desc排序的话null值可能会在数据的最前面.然而有时候我们查看数据的时候并不希望能够在前面看到这些null值的排序数据. 因此我查了一下: 1.排序的时候运用nvl(). ...

  9. 检索数据_22_根据数据项的值排序

    根据数据项的值排序 需求描述 需求:查询雇员表emp里的员工编号.员工名.工作信息.奖金信息,这里需要对工作是"MANAGER"和"SALESMAN"的按照co ...

最新文章

  1. 虚拟化--006 VCAC的sso配置成功
  2. 如何使用cout以全精度打印双精度值?
  3. mybatis配置时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...
  4. Linux-鸟菜-4-关机的正确姿势
  5. html 如何判断文本溢出,判断文本是否溢出
  6. NYOJ 298 点的变换(矩阵快速幂)
  7. python的for语句有几种写法_Python if 和 for 的多种写法
  8. Centos-启动network报错RTNETLINK answers: File exists解决方法
  9. Spring框架 JdbcTemplate类 @Junit单元测试,可以让方法独立执行 如:@Test
  10. 手把手教你使用Python+scrapy爬取山东各城市天气预报
  11. 一步一步写算法(之单向链表)
  12. 计算机组成原理—第4章数值的机器运算
  13. 解决:log4j警告:WARN Please initialize the log4j system properly
  14. 综合计算增长比例计算机,比如2001-2010这10年GDP年均增长率怎么计算?
  15. 网络接口 FE GE 10GE SFP
  16. 计算机模拟需要什么配置电脑,网易MuMu模拟器对电脑配置的最低要求介绍
  17. 深度剖析家用洗地机的方案设计
  18. MFC技术内幕系列之(一)---MFC应用程序“生死因果”内幕
  19. EOS智能合约开发系列(16): deferred action与inline action
  20. 鼠标悬停 -css如何实现鼠标移至图片上显示遮罩层及文字

热门文章

  1. linux内核mtd驱动程序与sd卡驱动程序,Linux内核MTD驱动程序与SD卡驱动程序(2)
  2. ArcGIS Maritime Server 开发教程(四)Maritime Service 开发实践
  3. JQuery使用总结
  4. DataSet运用DES加解密到Xml
  5. javaweb编辑器ckeditor配置_ckeditor编辑器在java项目中配置
  6. 【java学习之路】(java SE篇)012.网络编程
  7. 二、RabbitMQ常用交换器
  8. 时空复杂度(时间复杂度/空间复杂度)O(1)、O(n)、O(n^2)、O(log n)、O(n log n)是什么意思,借鉴 然后自己借鉴出来
  9. linux 网络对讲,基于ARM与Linux的全数字化可视对讲系统的设计与实现
  10. 本计算机无法加入家庭组,win10系统无法加入家庭组是怎么回事?