首先检测有木有和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. takeLatest 如何接受 this.props.dispatch 传递的参数

    1.步骤一 // 获取查询参数 getQueryParams(params){ // 请求月考核分的数据 this.props.dispatch({ type:'getMonthlyAssessmen ...

  2. 【iOS】系统框架学习

    iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa Touch l ...

  3. Desktop Management Interface & System Management BIOS

    http://en.wikipedia.org/wiki/Desktop_Management_Interface Desktop Management Interface From Wikipedi ...

  4. 写2个线程,其中一个线程打印1~52,另一个线程打印A~z,打印顺序应该是12A34B45C……5152Z

    我写的 class LN { private int flag = 0; public static char ch = 'A'; public static int n = 1; public sy ...

  5. HashMap源代码学习笔记

        HashMap的底层主要是基于数组和链表来实现的,它之所以有相当快的查询速度主要是由于它是通过计算散列码来决定存储的位置. HashMap中主要是通过key的hashCode来计算hash值的 ...

  6. TinyXML:TiXmlNode

    TiXmlNode: 对应于DOM结构中的节点,是TinyXML中很重要的一个类,它继承自TiXmlBase TiXmlNode的友元类: friend class TiXmlDocument; fr ...

  7. 跨平台C++:(前言)正确打开C++的方式

    接触C++已经十五年了...但是对于C++而言,我至今是个门外汉,不是谦虚,而是确实不得其门而入. 历程是这样的—— 大学考研要考C++,就自学了.研没考上,C++算是学了,准确的说是C++的语法,以 ...

  8. python day 13 生成器 以及 推导式

    1.生成器的本质是迭代器 2.生成器函数 def  fn() 函数体 yield fn() g = fn() 此时这个g就是生成器 所以g 是可迭代的 g._ _next_ _ 每执行一次_ _nex ...

  9. Codeforces Round #422 (Div. 2) B. Crossword solving 枚举

    B. Crossword solving     Erelong Leha was bored by calculating of the greatest common divisor of two ...

  10. hihocode #1388 : Periodic Signal NTT

    #1388 : Periodic Signal   描述 Profess X is an expert in signal processing. He has a device which can ...