思路:

在一堆服务器中,资源最少的那一个是“瓶颈”,由此想到贪心思路。

首先对所有服务器按照资源数量c排序,再从头到尾扫描。对每个位置,根据x1和x2计算出两段连续的服务器集合分别分配给A任务和B任务(还需要枚举分配A和B的先后顺序),如果够用,则有解。所有位置都不行,则无解。

实现:

 #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
pii c[];
int n, x1, x2;
vector<int> check(int a, int b)
{
bool flg = false;
int tmp, tmp2, l, l2, i = ;
for ( ; i < n; i++)
{
tmp = c[i].first; l = (a + tmp - ) / tmp;
if (i + l >= n) continue;
tmp2 = c[i + l].first; l2 = (b + tmp2 - ) / tmp2;
if (i + l + l2 > n) continue;
flg = true; break;
}
vector<int> ans;
if (flg) { ans.push_back(i); ans.push_back(l); ans.push_back(l2); }
return ans;
}
void show(vector<int> & v, bool rev)
{
vector<int> v1, v2;
for (int i = v[]; i < v[] + v[]; i++) v1.push_back(c[i].second);
for (int i = v[] + v[]; i < v[] + v[] + v[]; i++) v2.push_back(c[i].second);
cout << "Yes" << endl;
if (rev)
{
cout << v[] << " " << v[] << endl;
for (auto it: v2) cout << it << " ";
cout << endl;
for (auto it: v1) cout << it << " ";
cout << endl;
}
else
{
cout << v[] << " " << v[] << endl;
for (auto it: v1) cout << it << " ";
cout << endl;
for (auto it: v2) cout << it << " ";
cout << endl;
}
}
int main()
{
while (cin >> n >> x1 >> x2)
{
for (int i = ; i < n; i++) { cin >> c[i].first; c[i].second = i + ; }
sort(c, c + n);
vector<int> ans = check(x1, x2);
if (ans.size()) { show(ans, false); continue; }
ans = check(x2, x1);
if (ans.size()) { show(ans, true); continue; }
cout << "No" << endl;
}
return ;
}

CF967D Resource Distribution的更多相关文章

  1. 【枚举】【二分】Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D. Resource Distribution

    题意:有两个服务要求被满足,服务S1要求x1数量的资源,S2要求x2数量的资源.有n个服务器来提供资源,第i台能提供a[i]的资源.当你选择一定数量的服务器来为某个服务提供资源后,资源需求会等量地分担 ...

  2. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1

    P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1       May ...

  3. How to Analyze Java Thread Dumps--reference

    原文地址:http://architects.dzone.com/articles/how-analyze-java-thread-dumps The Performance Zone is pres ...

  4. CodeForces round 967 div2 题解(A~E)

    本来准备比完赛就写题解的, 但是一拖拖了一星期, 唉 最后一题没搞懂怎么做,恳请大神指教 欢迎大家在评论区提问. A Mind the Gap 稳定版题面 https://cn.vjudge.net/ ...

  5. How to Analyze Java Thread Dumps

    When there is an obstacle, or when a Java based Web application is running much slower than expected ...

  6. PatentTips - Method and system for browsing things of internet of things on ip using web platform

    BACKGROUND The following disclosure relates to a method and system for enabling a user to browse phy ...

  7. Karmada大规模测试报告发布:突破100倍集群规模

    摘要:在本文中,我们将介绍用于测试的相关指标,如何进行大规模测试,以及我们如何实现大规模的集群接入. 本文分享自华为云社区<突破100倍集群规模!Karmada大规模测试报告发布>,作者: ...

  8. 齐夫定律, Zipf's law,Zipfian distribution

    齐夫定律(英语:Zipf's law,IPA英语发音:/ˈzɪf/)是由哈佛大学的语言学家乔治·金斯利·齐夫(George Kingsley Zipf)于1949年发表的实验定律. 它可以表述为: 在 ...

  9. CG&CAD resource

    Computational Geometry The Geometry Center (UIUC) Computational Geometry Pages (UIUC) Geometry in Ac ...

随机推荐

  1. mysql数据库隔离级别及其原理、Spring的7种事物传播行为

    一.事务的基本要素(ACID) 1.原子性(Atomicity):事务开始后所有操作,要么全部做完,要么全部不做,不可能停滞在中间环节.事务执行过程中出错,会回滚到事务开始前的状态,所有的操作就像没有 ...

  2. Your Firefox profile cannot be loaded. It may be missing or inaccessible

    ubuntu下出现打开frefox出现Your Firefox profile cannot be loaded. It may be missing or inaccessible 1:用命令行输入 ...

  3. vue中导出Excel表格

    项目中我们可能会碰到导出Excel文件的需求,一般后台管理系统中居多,将table中展示的数据导出保存到本地.当然我们也可以通过一些处理来修改要导出的数据格式,具体需求具体对待. 1.首先我们需要安装 ...

  4. 5.3linux下C语言socket网络编程简例

    原创文章,转载请注明转载字样和出处,谢谢! 这里给出在Linux下的简单socket网络编程的实例,使用tcp协议进行通信,服务端进行监听,在收到客户端的连接后,发送数据给客户端:客户端在接受到数据后 ...

  5. react native 之页面跳转

    第一章  跳转的实现 1.component  中添加这行代码 <View style={styles.loginmain}> <Text style={styles.loginte ...

  6. Ubuntu安装mycli,让mysql命令行可以自动提示

    安装mycli 1.确保有安装python 2.确保有安装pip 3.进入su模式,以管理员身份安装 4.安装 pip install -U mycli 5.登录 mycli -u root 很好很强 ...

  7. poj 2771 Guardian of Decency(最大独立数)

    题意:人与人之间满足4个条件之一即不能成为一对(也就说这4个条件都不满足才能成为一对),求可能的最多的单身人数. 思路:把男女分为两部分,接下来就是二分图的匹配问题.把能成为一对的之间连边,然后求出最 ...

  8. 原:maven+springMVC+mybatis+junit详细搭建过程

    阅读目录 1.  工程目录结构整理清楚 2.  引入依赖包 3. 配置数据库连接属性 4.  配置spring配置文件 5.  java代码编写(model,dao,service层代码) 6.  m ...

  9. HDUoj4857逃生 拓扑排序

    逃生 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...

  10. Servlet分页查询

    分页查询: 1.逻辑分页查询:用户第一次访问时就把全部数据访问出来,添加到一个大集合中,然后放到session中,进行转发.通过页码等的计算,把要显示的内容添加到一个小集合中,转发.遍历小集合以显示当 ...