思路:

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

首先对所有服务器按照资源数量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 ;
}

最新文章

  1. 获取 windows 商店内的 aapx 安装包 并 安装(旁加载)
  2. [原创]基于rsync算法的目的性改进-RexSync
  3. ecmall源码中的 function _config_view()-关于重写
  4. python 列表常用操作
  5. 第13章 Windows内存体系结构
  6. linux 使用 pyodbc 访问 ms sqlserver 数据库
  7. php安全设定
  8. UESTC 1425 Another LCIS
  9. CSS3弹性盒模型布局模块
  10. temp-mootools简单语法
  11. Netty学习笔记(一):接收nodejs模拟表单上传的文件
  12. linux shell set命令
  13. 五大理由分析Springboot 2.0为什么选择HikariCP
  14. mysql 游标的使用方法
  15. re_test
  16. 为什么会出现container/injection的思想?
  17. 知识图谱实战开发案例剖析-番外篇(1)- Neo4j是否支持按照边权重加粗和大数量展示
  18. 怎样从外网访问内网WebSphere?
  19. curl请求指定host ip(指定域名解析的内网某ip)
  20. Redis设置密码重启后失效的解决方案

热门文章

  1. Awesome Adb——一份超全超详细的 ADB 用法大全【转】
  2. ap和路由器有什么区别 ap和路由器的区别介绍【图文】
  3. pkg-config相关
  4. Java中文&amp;编码问题小结
  5. 用mkdirs创建目录
  6. Spring配置错误 No adapter for IAdvice of type
  7. codeforces round 421 div2 补题 CF 820 A-E
  8. bzoj3143游走——期望+高斯消元
  9. 【旧文章搬运】Windbg+Vmware驱动调试入门(四)---VirtualKD内核调试加速工具
  10. 【旧文章搬运】Windbg+Vmware驱动调试入门(二)---Vmware及GuestOS的设置