Hiking

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 492    Accepted Submission(s): 263

Special Judge

Problem Description
There are n soda
conveniently labeled by 1,2,…,n.
beta, their best friends, wants to invite some soda to go hiking. The i-th
soda will go hiking if the total number of soda that go hiking except him is no less than li and
no larger than ri.
beta will follow the rules below to invite soda one by one:

1. he selects a soda not invited before;

2. he tells soda the number of soda who agree to go hiking by now;

3. soda will agree or disagree according to the number he hears.



Note: beta will always tell the truth and soda will agree if and only if the number he hears is no less than li and
no larger than ri,
otherwise he will disagree. Once soda agrees to go hiking he will not regret even if the final total number fails to meet some soda's will.



Help beta design an invitation order that the number of soda who agree to go hiking is maximum.
 
Input
There are multiple test cases. The first line of input contains an integer T,
indicating the number of test cases. For each test case:



The first contains an integer n (1≤n≤105),
the number of soda. The second line constains n integers 

posted on 2017-05-06 17:53 cynchanpin 阅读(...) 评论(...) 编辑 收藏

var allowComments=true,cb_blogId=347763,cb_entryId=6817500,cb_blogApp=currentBlogApp,cb_blogUserGuid='43c87c18-831e-e711-9fc1-ac853d9f53cc',cb_entryCreatedDate='2017/5/6 17:53:00';loadViewCount(cb_entryId);var cb_postType=1;var isMarkdown=false;

HDU 5360 Hiking(优先队列)的更多相关文章

  1. hdu 5360 Hiking(优先队列+贪心)

    题目:http://acm.hdu.edu.cn/showproblem.php? pid=5360 题意:beta有n个朋友,beta要邀请他的朋友go hiking,已知每一个朋友的理想人数[L, ...

  2. HDU 5360 Hiking(优先队列)2015 Multi-University Training Contest 6

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total S ...

  3. 2015多校第6场 HDU 5360 Hiking 贪心,优先队列

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5360 题意:给定n个人,现在要邀请这些人去远足,但每个人同意邀请的条件是当前已经同意去远足的人数c必须 ...

  4. HDU 5360——Hiking——————【贪心+优先队列】

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  5. HDU 5360 Hiking 登山 (优先队列,排序)

    题意: 有n个人可供邀请去hiking,但是他们很有个性,每个人都有个预期的人数上下限[Li,Ri],只有当前确定会去的人数在这个区间内他才肯去.一旦他答应了,无论人数怎样变更,他都不会反悔.问最多能 ...

  6. HDOJ 5360 Hiking 优先队列+贪心

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5360 题意: 大概的意思就是每个人有个人数接受范围$[l_i,r_i]$,现在你每次能从还未被选取的人 ...

  7. 2015 Multi-University Training Contest 6 hdu 5360 Hiking

    Hiking Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  8. HDU 5360 Hiking (贪心)

    题意:邀请 n 参加聚会,如果在邀请第 i 个人之前,已经成功邀请了 x 个人,并且 li <= x <= ri,那么第 i 人才会去,问你怎么排列使得邀请的人最多. 析:对于所有的人,按 ...

  9. HDU 5360 【优先队列+贪心】

    题意: 给定N个无序区间. 对合法区间的定义是: 在这个区间之前已经选出了至少l个合法区间,最多选出了r个合法区间.则该区间为合法区间. 输出最多能挑选出多少个合法区间,并输出合法区间的数量. 思路: ...

随机推荐

  1. java中常用的几种缓存类型介绍

    在平时的开发中会经常用到缓存,比如locache.redis等,但一直没有对缓存有过比较全面的总结.下面从什么是缓存.为什么使用缓存.缓存的分类以及对每种缓存的使用分别进行分析,从而对缓存有更深入的了 ...

  2. Python-S9-Day123——爬虫两示例

    01 今日内容回顾 02 内容回顾和补充:面向对象约束 03 爬虫之抽屉新热榜 04 爬虫之抽屉自动登录(一) 05 爬虫之抽屉自动登录(二) 06 爬虫之登录github(一) 07 爬虫之登录gi ...

  3. C# 序列化和反序列化 详解

    什么是序列化以及如何实现序列化? 如何将对象数据写入 XML 文件? 如何从 XML 文件读取对象数据? 什么是序列化以及如何实现序列化? 序列化是通过将对象转换为字节流,从而存储对象或将对象传输到内 ...

  4. 14 Java虚拟机实现 synchronized

    java 中的 synchronized 运行 在 Java 中,我们经常用 synchronized 关键字对程序进行加锁.无论是一个代码块还是静态方法或者实例方法,都可以直接用 synchroni ...

  5. 03 Java 虚拟机是如何加载 Java 类的

    Java 引用类型 Java 中的引用类型细分为四种:类,接口,数组类和泛型参数. 因为泛型参数会在编译过程中被擦除,所以 Java 虚拟机实际上只有前三种.数组类是由 Java 虚拟机直接生成的,其 ...

  6. HDU5862 Counting Intersections

    Given some segments which are paralleled to the coordinate axis. You need to count the number of the ...

  7. Spring AOP Example 文件下载:

      文件下载:http://files.cnblogs.com/wucg/spring_aop_excise.zip P:124 spring核心技术 P225: spring doc 可以把Advi ...

  8. proteus仿真 引脚显示电平变化但不能显示波形

    proteus仿真 引脚显示电平变化但不能显示波形 原来是没有选择通道问题,proteus默认优先使用A通道才会显示波形,如果优先使用B,C,D通道,需要选择...

  9. Codeforces #990E Post Lamp

    题目大意 今欲用若干条长为 $k$($1\le k\le m, k\in \mathbb{Z}$) 的线段覆盖数轴上 $[0,n]$ 这一段.线段的起点(左端点)必须为 $[0, n-1]$ 中的某个 ...

  10. 洛谷P3832 [NOI2017]蚯蚓排队 【链表 + 字符串hash】

    题目链接 洛谷P3832 题解 字符串哈希然后丢到hash表里边查询即可 因为\(k \le 50\),1.2操作就暴力维护一下 经复杂度分析会发现直接这样暴力维护是对的 一开始自然溢出WA了,还以为 ...