如果没有必选的限制条件,就是水题了、、、

只要按照w + t排序就可以了,然后搞个堆来维护

于是有了限制条件,还是水题。。。

到了必选的时候强制选上,不加入堆中即可。

 /**************************************************************
Problem: 1555
User: rausen
Language: C++
Result: Accepted
Time:2228 ms
Memory:10948 kb
****************************************************************/ #include <cstdio>
#include <cctype>
#include <algorithm>
#include <queue> using namespace std;
typedef long long ll;
const int N = ; struct data {
int w, t, f;
}a[N];
bool operator < (const data &a, const data &b) {
return (ll) a.w + a.t < (ll) b.w + b.t;
} ll tot, V;
int n, m, w, ans;
priority_queue <int> q; inline ll read() {
ll x = ;
char ch = getchar();
while (!isdigit(ch))
ch = getchar();
while (isdigit(ch)) {
x = x * + ch - '';
ch = getchar();
}
return x;
} inline void del_top() {
tot -= q.top(), q.pop();
--ans;
} inline void add(int x) {
tot += a[x].w, q.push(a[x].w);
++ans;
} bool work() {
int i;
tot = ;
for (i = ; i <= n; ++i)
if (a[i].f == ) {
while (tot > a[i].t) {
if (q.empty()) return ;
del_top();
}
tot += a[i].w, ++ans;
}else {
if (!q.empty() && tot > a[i].t)
if (q.top() < a[i].w || tot - q.top() > a[i].t)
continue;
if (tot > a[i].t)
del_top();
add(i);
}
return ;
} int main() {
int i, X;
n = read(), m = read(), V = read();
for (i = ; i <= n; ++i)
a[i].w = read(), a[i].t = read();
for (i = ; i <= m; ++i) {
X = read(), a[X].f = ;
tot += a[X].w;
}
sort(a + , a + n + );
a[++n].f = , a[n].t = V;
if (!work()) puts("Foolish SD!");
else printf("%d\n", ans - );
return ;
}

(p.s. 怎么又想开fread二笔优化了呢、、、233)

BZOJ1555 KD之死的更多相关文章

  1. bzoj1555 KD之死 贪心+堆优化

    1555: KD之死 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 124  Solved: 54[Submit][Status][Discuss] D ...

  2. BZOJ 1555 KD之死

    贪心,按t+w排序维护不一定放到拖车上的大根堆. #include<iostream> #include<cstdio> #include<cstring> #in ...

  3. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  4. k-d tree模板练习

    1. [BZOJ]1941: [Sdoi2010]Hide and Seek 题目大意:给出n个二维平面上的点,一个点的权值是它到其他点的最长距离减最短距离,距离为曼哈顿距离,求最小权值.(n< ...

  5. 一起KVM环境下windows7虚拟机异常死机(BSOD)的问题解决

    先说一下环境: 一.硬件 8台服务器做的超融合架构,软件存储池, 每台服务器是96G内存,两颗Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz,32线程. 每台服务器是 ...

  6. mysql每秒最多能插入多少条数据 ? 死磕性能压测

    前段时间搞优化,最后瓶颈发现都在数据库单点上. 问DBA,给我的写入答案是在1W(机械硬盘)左右. 联想起前几天infoQ上一篇文章说他们最好的硬件写入速度在2W后也无法提高(SSD硬盘) 但这东西感 ...

  7. wp已死,metro是罪魁祸首!

    1.这篇文章肯定会有类似这样的评论:“我就是喜欢wp,我就是喜欢metro,我就是软粉“等类似的信仰论者发表的评论. 2.2014年我写过一篇文章,windows phone如何才能在中国翻身? 我现 ...

  8. APP测试点总结(功能,交互,死机崩溃状态分析,容易出错的检查点)

    APP测试点总结(功能,交互,死机崩溃状态分析,容易出错的检查点) 版权声明:本文为博主原创文章,未经博主允许不得转载. 最近涉足APP端测试,常见检查点总结如下:   一.业务方面: 1.  注册( ...

  9. 利用KD树进行异常检测

    软件安全课程的一次实验,整理之后发出来共享. 什么是KD树 要说KD树,我们得先说一下什么是KNN算法. KNN是k-NearestNeighbor的简称,原理很简单:当你有一堆已经标注好的数据时,你 ...

随机推荐

  1. MySQL 慢查询日志工具之pt-query-digest

    1. 工具简介 pt-query-digest是用于分析mysql慢查询的一个工具,它可以分析binlog.General log.slowlog,也可以通过SHOWPROCESSLIST或者通过tc ...

  2. android 错误收集

    2. is not translated in Eclipse > Preference > Android > Lint Error Checking的Correctness: M ...

  3. 【Python】接口自动化测试-Fidder的使用(未完待续……)

    一.fidder一些一定需要掌握的知识. 1.工具简介 2.清屏操作(1中提到了,这里再着重说明下): 3.get和post请求参数相关: 4.会话框(Fidder左侧区域内容解析): 5.Reque ...

  4. Windows mysql默认字符集修改

    一.通过MySQL命令行修改: set character_set_client=utf8; set character_set_connection=utf8; set character_set_ ...

  5. java打印随机函数

    一 ,打印1-10的随机函数 public static void randomprint(){      for (int i=0;i<100;i++){          //打印一百次  ...

  6. 3.7 Templates -- Links

    一.The {{link-to}} Helper 1. 使用{{link-to}}创建一个指向route的链接: app/router.js Router.map(function() { this. ...

  7. 小论“Boolean参数作为入参”的函数

    <Clean Code>一书中对于如何写好函数有着很动人的描写,其中对于函数参数的建议有如下两点: 函数参数的数量应该尽可能少 给一个一元函数传入bool类型的参数很"罪恶&qu ...

  8. java之标记型接口Cloneable

    1.克隆用途. Cloneable和Serializable一样都是标记型接口,它们内部都没有方法和属性,implements Cloneable表示该对象能被克隆,能使用Object.clone() ...

  9. hdu6158 The Designer

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6158 题目: The Designer Time Limit: 8000/4000 MS (J ...

  10. zwPython,字王集成式python开发平台,比pythonXY更强大、更方便。

    zwPython,字王集成式python开发平台,比pythonXY更强大.更方便. 更强大,内置opencv.cuda/opencl.NLTK自然语言.pygame游戏设计等多个重量级模块库. 更方 ...