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 ...
随机推荐
- 再回首,Java温故知新(九):Java基础之流程控制语句
流程控制语句分为条件语句.循环语句和中断语句. 中断语句包括break和continue,两者的区别在于break会跳出整个循环,而continue则是跳出此次循环,之后还会继续下一次循环. 条件语句 ...
- linux下MySQL安装登录及操作
linux下MySQL安装登录及操作 二.安装Mysql 1.下载MySQL的安装文件 安装MySQL需要下面两个文件: MySQL-server-4.0.16-0.i386.rpm MySQL-cl ...
- Programming a Spider in Java 源码帖
Programming a Spider in Java 源码帖 Listing 1: Finding the bad links (CheckLinks.java) import java.awt. ...
- Java基础知识强化之集合框架笔记36:List练习之键盘录入多个数据在控制台输出最大值
1. 键盘录入多个数据,以0结束,要求在控制台输出这多个数据中的最大值 分析: • 创建键盘录入数据对象 • 键盘录入多个数据,我们不知道多少个,所以用集合存储 • 以0结束,这个简单,只要键盘 ...
- Java设计模式03:常用设计模式之单例模式(创建型模式)
1. Java之单例模式(Singleton Pattern ) 单例模式是一种常见的设计模式,单例模式分三种:懒汉式单例.饿汉式单例.登记式单例三种. 单例模式有一下特点: 1.单例类只能有一个实 ...
- css考核点整理(十)-响应式开发经验,响应式页面的三种核心技术是什么
响应式开发经验,响应式页面的三种核心技术是什么
- css培训(三)
优先级 z-index 不设置 或auto 非static z-index :0 : z-index:-1: opacity 与层叠上下 opacity:.9 对其影响 小于1值 不具备堆叠 ...
- AIX系统上压缩与解压文件
压缩. 命令格式: #tar -cvf (或xvf)+文件名+设备 C:是本地到其他设备 x:是其他设备到本地 r:是追加,比如打包时,将其他文件追加进来使用该参数. t:显示tar包里的内容,但还原 ...
- 快速打出System.out.println("");
sysout---->Alt+/--->System.out.println():
- 如何在获取Datarow对象在其所属DataTable中的Index
做项目的时候需要先select一个DataTable的子集,后来又需要子集中这些DataRow的Index, 这个需求本来就有些奇怪,网上也没搜到.刚开始走了很多弯路,后来发现一个简便方法 'dr是你 ...