首先检测有木有和Computer匹配的Socket,如果有则将其匹配。

然后将所有没有匹配的Socket连上Adapter,再去检测有木有Computer与Socket匹配。

重复这个操作31次,所有Socket的power都变成1了,如果再不能匹配就结束程序。

 #include <bits/stdc++.h>
using namespace std; struct PC
{
int power;
int idx;
friend bool operator< (const PC& a, const PC& b)
{
return a.power < b.power;
}
};
int s[];
bool vis[];
int a[];
int b[]; int main()
{
int n, m;
scanf("%d%d", &n, &m);
multiset<PC> pc;
int p;
for (int i = ; i <= n; i++)
{
scanf("%d", &p);
pc.insert({p, i});
}
for (int i = ; i <= m; i++)
scanf("%d", s + i);
int c = , u = ;
for (int i = ; i < ; i++)
{
for (int j = ; j <= m; j++)
{
if (!vis[j])
{
multiset<PC>::iterator it = pc.find({s[j], });
if (it != pc.end())
{
b[it->idx] = j;
vis[j] = true;
pc.erase(it);
c++;
u += a[j];
}
}
}
for (int j = ; j <= m; j++)
if (!vis[j])
a[j]++, s[j] = (s[j] + ) / ;
}
printf("%d %d\n", c, u);
for (int i = ; i <= m; i++)
printf("%d ", vis[i] ? a[i] : );
puts("");
for (int i = ; i <= n; i++)
printf("%d ", b[i]);
return ;
}

Codeforces732E Sockets的更多相关文章

  1. HTML5权威指南--Web Storage,本地数据库,本地缓存API,Web Sockets API,Geolocation API(简要学习笔记二)

    1.Web Storage HTML5除了Canvas元素之外,还有一个非常重要的功能那就是客户端本地保存数据的Web Storage功能. 以前都是用cookies保存用户名等简单信息.   但是c ...

  2. Net.Sockets

    #region 程序集 System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program ...

  3. 联不上网 Unable to initialize Windows Sockets interface. General failure.

    电脑莫名联不上网 Unable to initialize Windows Sockets interface. General failure. Unable to initialize the W ...

  4. Unrecognized Windows Sockets error: 0: JVM_Bind 异常怎么办

    Unrecognized Windows Sockets error: 0: JVM_Bind 异常解决办法 java.net.SocketException: Unrecognized Window ...

  5. System.Net.Sockets.Socket SendAsync System.ObjectDisposedException: Cannot access a disposed object.

    发生未处理的域异常! System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net ...

  6. Socket Programming in C#--Multiple Sockets

    Now lets say you have two sockets connecting to either two different servers or same server (which i ...

  7. ava.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (解决思路)

    当我们在启动tomcat服务的时候报错信息:java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bin 分析:从错 ...

  8. Unrecognized Windows Sockets error: 0: JVM_Bind

    Unrecognized Windows Sockets error: 0: JVM_Bind [转帖]今天很是奇怪,在运行服务器端的时候,经常遇到这个异常: java.net.SocketExcep ...

  9. weblogic sockets 和 thread 问题解决

    原创文章,转载须注明出处. 这个问题网上很多答案,可惜没一个能解决.后来发现是weblogic 必须适配JDK 版本. 一般会报这个错误,There are: 5 active sockets, bu ...

随机推荐

  1. pomelo加入定时任务

    需求:在arenaserver下添加一个rank定时任务,每一分钟对对玩家进行一次排行. 首先在game-server/app/servers/arena文件夹下添加cron文件夹. 在game-se ...

  2. linked-list-cycle-ii——链表,找出开始循环节点

    Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. Follo ...

  3. 设计模式之命令模式(Command)摘录

    23种GOF设计模式一般分为三大类:创建型模式.结构型模式.行为模式. 创建型模式抽象了实例化过程,它们帮助一个系统独立于怎样创建.组合和表示它的那些对象.一个类创建型模式使用继承改变被实例化的类,而 ...

  4. [转载]php 数组 类对象 值传递 引用传递 区别

    一般的数据类型(int, float, bool)不做这方面的解说了 这里详细介绍一下数组和的类的对象作为参数进行值传递的区别 数组值传递 实例代码: <?php function main() ...

  5. Java小日历

    自己写的一个小小日历.执行程序是柯自己主动定位到当前年月日,当点击下个月button是会定位到下个月的这一天,就是说天数不会变.当在一个月中点击某一天时,以下的时间也会随时变化. import jav ...

  6. iOS simulator+Appium

    Why are you trying to run iOS automation on a real device? That's a bad idea. iOS Automation on a re ...

  7. win7 64位安装vs2013 出现'System.AccessViolationException的错误

    用管理员身份运行CMD,输入netsh winsock reset并回车(注意,必须是已管理员身份运行,这个重置LSP连接)

  8. C# delegate Action<T> lambda表达式

    转载以记录:http://blog.csdn.net/educast/article/details/7219854 在使用 Action<T> 委托时,不必显式定义一个封装只有一个参数的 ...

  9. 提升自身的iOS编程水平 (转载)

    阅读博客 在现在这个碎片化阅读流行的年代,博客的风头早已被微博盖过.而我却坚持写作博客,并且大量地阅读同行的iOS开发博客.博客的文章长度通常在3000字左右,许多iOS开发知识都至少需要这样的篇幅才 ...

  10. Vue实现仿淘宝商品详情属性选择的功能

    Vue实现仿淘宝商品详情属性选择的功能 先看下效果图:(同个属性内部单选,属性与属性之间可以多选) 主要实现过程: 所使用到的数据类型是(一个大数组里面嵌套了另一个数组)具体格式如下:   attrA ...