最高的奖励

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
 
描述

请问:挖掘机技术哪家强?AC了告诉你!

给你N(N<=3*10^4)个任务,每个任务有一个截止完成时间t(1=<t<=10^9)和完成该任务的奖励v(1=<v<=10^9),每个任务要花一天完成,问最多能获得多少奖励?

 
输入
多组 测试数据。
第一行一个数N,表示任务总数。
接下来N行,每行两个数t和v,如上所述。
输出
对于每组数据输出最高的奖励。
样例输入
7
4 20
2 60
4 70
3 40
1 30
4 50
6 10
样例输出
230
来源
51nod
上传者
TC_赵坤垚

解题:优先队列。。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#define LL long long
#define INF 0x3f3f3f3f
#define pii pair<int,int>
using namespace std;
const int maxn = ;
pii d[maxn];
int main(){
int n,u,v;
priority_queue< pii,vector< pii >,greater< pii > > q;
while(~scanf("%d",&n)){
LL ans = ;
while(!q.empty()) q.pop();
for(int i = ; i < n; ++i)
scanf("%d %d",&d[i].first,&d[i].second);
sort(d,d+n);
for(int i = ; i < n; ++i){
if(q.size() < d[i].first){
ans += d[i].second;
q.push(make_pair(d[i].second,d[i].first));
}else if(q.size() == d[i].first){
if(d[i].second > q.top().first){
ans += d[i].second - q.top().first;
q.pop();
q.push(make_pair(d[i].second,d[i].first));
}
}
}
printf("%lld\n",ans);
}
return ;
}

NYIST 1107 最高的奖励的更多相关文章

  1. NYOJ 1107 最高的奖励(贪心+优先队列)

    最高的奖励 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 请问:挖掘机技术哪家强?AC了告诉你! 给你N(N<=3*10^4)个任务,每个任务有一个截止完成时 ...

  2. Bzoj1076 [SCOI2008]奖励关

    Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1935  Solved: 1053 Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一 ...

  3. 【bzoj1076】 SCOI2008—奖励关

    http://www.lydsy.com/JudgeOnline/problem.php?id=1076 (题目链接) 题意 一个奖励,K次抛出宝物的机会,每次抛出都等概率的抛出n个物品中的一个,每个 ...

  4. 【bzoj1076】[SCOI2008]奖励关

    题目描述 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的宝物以后也不能再 ...

  5. 【BZOJ1076】[SCOI2008]奖励关 状压DP+期望

    [BZOJ1076][SCOI2008]奖励关 Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须 ...

  6. ACM: NBUT 1107 盒子游戏 - 简单博弈

     NBUT 1107  盒子游戏 Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:  Practice  Appoint ...

  7. nyist 78 圈水池

    http://acm.nyist.net/JudgeOnline/problem.php?pid=78 圈水池 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 有一个 ...

  8. 【BZOJ-1076】奖励关 概率与期望 + 状态压缩DP

    1076: [SCOI2008]奖励关 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1602  Solved: 891[Submit][Status ...

  9. POJ - 1107 W's Cipher

    POJ - 1107 W's Cipher Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u De ...

随机推荐

  1. ActiveMQ 整合 spring

    一.添加 jar 包 <dependency> <groupId>org.apache.activemq</groupId> <artifactId>a ...

  2. MyBatis-Spring-SqlSessionFactoryBean(转)

    SqlSessionFactoryBean 在基本的 MyBatis 中,session 工厂可以使用 SqlSessionFactoryBuilder 来创建.而在 MyBatis-Spring 中 ...

  3. http数据绑定spring mvc详解

  4. 在 Eclipse 中使用 C++

    安装 安装Eclipse Eclipse下载页 能够选择Eclipse IDE for C/C++ Developers(内置CDT插件) 也能够选择安装其它版本号之后再安装CDT插件. 安装CDT插 ...

  5. CodeForces--609C --Load Balancing(水题)

    Load Balancing Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Subm ...

  6. 如何让NSURLConnection在子线程中运行

    可以有两个办法让NSURLConnection在子线程中运行,即将NSURLConnection加入到run loop或者NSOperationQueue中去运行. 前面提到可以将NSTimer手动加 ...

  7. Ubuntu下推荐安装软件

    前言:都是全平台软件,通用性好. 1.搜狗输入法 官网下载: 不能双击.deb安装成功,需要安装依赖,可参考:https://www.cnblogs.com/chendeqiang/p/1017741 ...

  8. HTML文档 html,html5,css,css3

    HTML 各种标签及简单应用: http://www.w3school.com.cn 1 <p><p> 2 <br/> 3 <hr/>横线 4 < ...

  9. Zeplin(for Windows)无缝集成到了 Adobe XD

    Zeplin(for Windows)无缝集成到了 Adobe XD 大约6个月前,推出了 Zeplin 的新Adobe XD CC集成.从那时起,数十万个设计从Adobe XD导出到Zeplin.Z ...

  10. mysql学习 2

    1.建立外键 create table <表名>( <字段> 字段类型 not null, <字段> 字段类型 not null, <字段> 字段类型 ...