Preparing for the Contest
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int N=1e5+;
struct Node{
int val;
int id;
bool operator<(const Node a)const{
return val<a.val;
}
}task[N];
struct Edge{
int b;
int c;
int id;
bool operator<(const Edge a)const{
return b<a.b;
}
}stu[N];
struct result{
int id;
int cost;
bool operator<(const result a)const{
return cost>a.cost;
}
};
int ans[N],temp[N];
int n,m,s;
bool judge(int t){
int len=m,p=n,tp=s;
priority_queue<result>Q;
while(len>=){
while(p>=&&stu[p].b>=task[len].val){
result aaa;
aaa.cost=stu[p].c;
aaa.id=stu[p].id;
Q.push(aaa);
p--;
}
if(Q.size()==)return false;
result ta=Q.top();
Q.pop();
tp-=ta.cost;
if(tp<)return false;
for(int i=max(,len-t);i<=len;i++)
ans[task[i].id]=ta.id;
len-=t;
}
for(int i=;i<=m;i++)
temp[i]=ans[i];
return true;
}
int main(){
while(~scanf("%d%d%d",&n,&m,&s)){
for(int i=;i<=m;i++){
scanf("%d",&task[i].val);
task[i].id=i;
}
for(int i=;i<=n;i++)
scanf("%d",&stu[i].b);
for(int i=;i<=n;i++){
scanf("%d",&stu[i].c);
stu[i].id=i;
}
sort(task+,task+m+);
sort(stu+,stu+n+);
int minn=-,l=,r=m;
while(l<=r){
int mid=(l+r)/;
if(judge(mid)){
r=mid-;
minn=mid;
}
else l=mid+;
}
if(minn==-)printf("NO\n");
else{
printf("YES\n");
for(int i=;i<=m;i++){
printf("%d ",temp[i]);
}
printf("\n");
}
}
}
Preparing for the Contest的更多相关文章
- Codeforces Round #222 (Div. 1) B. Preparing for the Contest 二分+线段树
B. Preparing for the Contest 题目连接: http://codeforces.com/contest/377/problem/B Description Soon ther ...
- 【CF】222 Div.1 B Preparing for the Contest
这样类似的题目不少,很多都是一堆优化条件求最优解,这个题的策略就是二分+贪心.对时间二分, 对费用采用贪心. /* 377B */ #include <iostream> #include ...
- codeforces 377B Preparing for the Contest 二分+优先队列
题目链接 给你m个bug, 每个bug都有一个复杂度.n个人, 每个人有两个值, 一个是能力值, 当能力值>=bug的复杂度时才可以修复这个bug, 另一个是雇佣他需要的钱,掏一次钱就可以永久雇 ...
- CodeForces 377B---Preparing for the Contest(二分+贪心)
C - Preparing for the Contest Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d ...
- POJ3967Ideal Path[反向bfs 层次图]
Ideal Path Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 1754 Accepted: 240 Descri ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- uav 11258 String Partition (DP)
Problem F - String Partition ...
- UVA1599-Ideal Path(BFS进阶)
Problem UVA1599-Ideal Path Time Limit: 3000 mSec Problem Description New labyrinth attraction is ope ...
- Codeforces Round #222 (Div. 1) (ABCDE)
377A Maze 大意: 给定棋盘, 保证初始所有白格连通, 求将$k$个白格变为黑格, 使得白格仍然连通. $dfs$回溯时删除即可. #include <iostream> #inc ...
随机推荐
- android 20 Intnet类重要的成员变量
Intnet类重要的成员变量: <intent-filter> <action android:name="android.intent.action.MAIN" ...
- MVCC
http://blog.chinaunix.net/xmlrpc.php?id=3886838&r=blog/article&uid=26664667
- 使用Partitioner实现输出到多个文件
1.需求 按学生的年龄段,将数据输出到不同的文件.这里我们分为三个年龄段:小于等于20岁.大于20岁小于等于50岁和大于50岁 2.实现 1.编写Partitioner,代码如下 public sta ...
- 使用org.apache.jasper.JspC编译jsp文件--转载
JspC可以通过jspc.setArgs(args);设置所需参数,和使用指令进行编译相同, 使用指令编译范例: java -cp jasper.jar;servlet-api.jar;Fcatali ...
- MyEclipse8.6安装svn(非link方式)
此方法经试验可行,暂时可以作为最佳解决方案. 本文所使用的MyEclipse版本为:8.6.1 svn的eclipse插件版本为:1.6.17,下载地址:http://subclipse.tigris ...
- jquery选择器取值和url正则匹配
用到的简单jquery知识,简单总结一下,一是能加深自己的记忆,二是方便自己以后查看.常言道"好记性不如烂笔头",要养成常总结.常记录的好习惯.慢慢的发现jquery很有意思,很强 ...
- Android Listview with different layout for each row
http://stackoverflow.com/questions/4777272/android-listview-with-different-layout-for-each-row 其关键在重 ...
- 在java中使用 File.renameTo(File)实现重命名.
Here is part of my files: [北京圣思园Java培训教学视频]Java.SE.前9日学习成果测试题(2010年12月2日).rar [北京圣思园Java培训教学视频]Java. ...
- PL/SQL Developer远程连接Oracle数据库
首先打开电脑,到pl/sql安装的指定目录[D:\app\DZL\product\11.2.0\dbhome_1\NETWORK\ADMIN]找到[tnsnames.ora] 打开[tnsna ...
- office2010怎么激活
软件都是不断更新换代的,像我们使用最多的Microsoft Office软件,从最初的98,2000,2003,2007,到现在的2010.但是在最初安装Office软件时,都是未激活的.下面介绍的就 ...