NYIST 1107 最高的奖励
最高的奖励
- 描述
-
请问:挖掘机技术哪家强?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 最高的奖励的更多相关文章
- NYOJ 1107 最高的奖励(贪心+优先队列)
最高的奖励 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 请问:挖掘机技术哪家强?AC了告诉你! 给你N(N<=3*10^4)个任务,每个任务有一个截止完成时 ...
- Bzoj1076 [SCOI2008]奖励关
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1935 Solved: 1053 Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一 ...
- 【bzoj1076】 SCOI2008—奖励关
http://www.lydsy.com/JudgeOnline/problem.php?id=1076 (题目链接) 题意 一个奖励,K次抛出宝物的机会,每次抛出都等概率的抛出n个物品中的一个,每个 ...
- 【bzoj1076】[SCOI2008]奖励关
题目描述 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须在抛出下一个宝物之前做出选择,且现在决定不吃的宝物以后也不能再 ...
- 【BZOJ1076】[SCOI2008]奖励关 状压DP+期望
[BZOJ1076][SCOI2008]奖励关 Description 你正在玩你最喜欢的电子游戏,并且刚刚进入一个奖励关.在这个奖励关里,系统将依次随机抛出k次宝物,每次你都可以选择吃或者不吃(必须 ...
- ACM: NBUT 1107 盒子游戏 - 简单博弈
NBUT 1107 盒子游戏 Time Limit:1000MS Memory Limit:65535KB 64bit IO Format: Practice Appoint ...
- nyist 78 圈水池
http://acm.nyist.net/JudgeOnline/problem.php?pid=78 圈水池 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 有一个 ...
- 【BZOJ-1076】奖励关 概率与期望 + 状态压缩DP
1076: [SCOI2008]奖励关 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1602 Solved: 891[Submit][Status ...
- POJ - 1107 W's Cipher
POJ - 1107 W's Cipher Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u De ...
随机推荐
- 循环时自动打开url
'systemutil.Run "C:\Program Files (x86)\HP\QuickTest Professional\samples\flight\app\flight4a.e ...
- 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!
Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: ...
- HDU 5168
把边按权值排序后,就相当于求一个子序列以1开始和以n结束.由于边权递增,而且相差>=k,所以,边的顺序也必定是递增的.知道,当处理一条出边时,必定是从入边选择一条最优的边,考虑两个因素,入边的权 ...
- rails create方法ActiveModel::ForbiddenAttribute的问题
rails create方法ActiveModel::ForbiddenAttribute的问题 def create @ad = Ad.new(ad_params) @ad.save end pri ...
- [Tailwind] Apply mobile-first Responsive Classes in Tailwind
In this lesson, we take a look at tailwind's mobile-first CSS architecture and learn how to apply st ...
- java 微信server录音下载到自己server
/** * @author why * */ public class VoiceDownload { /** * * 依据文件id下载文件 * * * * @param mediaId * * 媒体 ...
- [Tomcat]Tomcat安全设置
1.关闭服务器端口:server.xml默认有下面一行: <Server port="8005" shutdown="SHUTDOWN"> 这样允许 ...
- 更改python字符编码以便使用UTF-8的编码url路径
url编码分两种, 一种是unicode, 另一种是gb2312, 今天遇到的一个网站是要将字符编码按照gb2312来编码,用来得到一个先填写blanks后再返回页面的数据,废话少说,需要做的就是先查 ...
- POJ 2346 DP or打表
这题 不算重复的数.. 就变成水题了. 思路: 1.打表 2.DP 打表的: // by SiriusRen #include <cstdio> using namespace std; ...
- 微信小程序 | 小程序的转发问题
1.配置小程序页面静态转发信息 关于小程序转发问题,文档 在 page 页面填加了该监听函数,会在小程序右上角 ... 菜单中显示“转发”按钮: 监听函数需要 return {} 其中的内容配置转发信 ...