qduoj 195 Interesting Game
来源:互联网 发布:海绵城市计算软件 编辑:程序博客网 时间:2024/05/16 14:50
简单的贪心策略。
首先把所有兔子按照血量从大到小排序,依次解决。
如果当前解决的兔子血量为x,那么就从所有攻击力大于等于x的箭中取出价格最低的一个,用来消灭这只兔子。
注意,已经被使用的箭在之后不可再次被取出。
用一个小根堆来维护攻击力大于等于x的箭即可。
#include <queue>#include <cstdio>#include <algorithm>const int mxn = 50005;int n, m, b[mxn];struct data { int d, p; inline bool operator < (const data &that) const { return d > that.d; }} a[mxn];std::priority_queue< int, std::vector<int>, std::greater<int> > heap;signed main() { scanf("%d%d", &n, &m); for (int i = 1; i <= n; ++i) scanf("%d", b + i); for (int i = 1; i <= m; ++i) scanf("%d%d", &a[i].d, &a[i].p); std::sort(b + 1, b + n + 1); std::sort(a + 1, a + m + 1); int tot = 1; long long ans = 0; for (int i = n; i >= 1; --i) { while (tot <= m && a[tot].d >= b[i]) heap.push(a[tot++].p); if (heap.empty()) return puts("No Solution"); else ans += heap.top(), heap.pop(); } printf("%lld\n", ans); return 0;}
阅读全文
0 0
- qduoj 195 Interesting Game
- BUPT OJ148 An Interesting Game
- 【郑轻】[1760]Interesting game
- 图论专题 An Interesting Game
- HDU 3295 An interesting mobile game
- hdu3295 An interesting mobile game (IDA*)
- sdut2414 An interesting game 费用流
- HDU3295An interesting mobile game(BFS +模拟)
- hdu 3295 An interesting mobile game(bfs)
- SPOJ Interesting Game 1月6日
- SPOJ IGAME(Interesting Game-博弈+数位dp)
- spoj Interesting Game (数位dp+nim博弈)
- swustoj-A interesting game(0194)(博弈)
- interesting
- interesting
- Interesting!
- Interesting!
- hdu 3259 An interesting mobile game (dfs+bfs+模拟)
- [数据结构]图邻接矩阵C语言简单实现
- Ubuntu上安装redwoodHQ2.5.5
- C#设计模式之代理模式(二)
- [转载]65条最常用正则表达式,你要的都在这里了
- MediaPlayer的在start()之前拖拽seekBar没用?
- qduoj 195 Interesting Game
- 二叉查找树/二叉排序树/二叉搜索树----> BST
- pcf8951 ad/da(iic)转换模块 在 esp8266下的实现
- 悦花越有全返系统开发
- spring boot 热部署
- libopencv_nonfree.so.2.4: cannot open shared object file: No such file or directory
- 由roguelike《拾荒者》学习Unity(二)
- Springmvc表单防止重复提交
- 设计模式:工厂方法模式