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 ...
随机推荐
- TREEVIEW节点拖拽
http://files.cnblogs.com/xe2011/TreeView_Drag_and_Drop.rar 假设把A节点往B节点上拖拽 那么 A 为Node1,B为Node2 ...
- strstr和memcmp函数的实现
#include <stdio.h> #include <stdlib.h> //malloc()函数 typedef unsigned int size_t; size_t ...
- MST最小生成树及Prim普鲁姆算法
MST在前面学习了Kruskal算法,还有一种算法叫做Prim的.这两者的区别是Prim算法适合稠密图,比如说鸟巢这种几乎所有点都有相连的图.其时间复杂度为O(n^2),其时间复杂度与边的数目无关:而 ...
- 学习Oracle应该准备的技能
首先数据库方面的技能:数据库体系结构.基本概念和基本理论.数据库管理.备份.恢复.SQL开发.PLSQL开发.工具的使用等等. 操作系统方面的技能:对Linux/Unix系统应该有相当的基础.理解RA ...
- limit-进程句柄限制
在Linux下面部署应用的时候,有时候会遇上Socket/File: Can’t open so many files的问题,比如还有Squid做代理,当文件打开数到900多时速能就非常快的下降,有可 ...
- The BINARY and VARBINARY Types
mysql> CREATE TABLE t (c BINARY()); Query OK, rows affected (0.21 sec) mysql> INSERT INTO t SE ...
- JS实现一键复制功能
var copyClick = function (d) { var Url2 = $(d).parent().parent().find("#copy_value"); Url2 ...
- CI 笔记4 (easyui 手风琴)
添加父div标签,和子div标签 <div class="easyui-accordion" data-options="fit:true,border:false ...
- oracle中所有关于时间日期的问题总结
select current_date as 当前会话时间,sysdate as 系统时间, systimestamp as 系统详细时间 from dual;
- TextField的文字距左边框的距离偏移
默认情况下,当向textField输入文字时,文字会紧贴在textField左边框上. 我们可以通过设置textField的leftView,设置一个只有宽度的leftView. 这样还不够,因为默认 ...