Codeforces732E Sockets
首先检测有木有和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的更多相关文章
- HTML5权威指南--Web Storage,本地数据库,本地缓存API,Web Sockets API,Geolocation API(简要学习笔记二)
1.Web Storage HTML5除了Canvas元素之外,还有一个非常重要的功能那就是客户端本地保存数据的Web Storage功能. 以前都是用cookies保存用户名等简单信息. 但是c ...
- Net.Sockets
#region 程序集 System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program ...
- 联不上网 Unable to initialize Windows Sockets interface. General failure.
电脑莫名联不上网 Unable to initialize Windows Sockets interface. General failure. Unable to initialize the W ...
- Unrecognized Windows Sockets error: 0: JVM_Bind 异常怎么办
Unrecognized Windows Sockets error: 0: JVM_Bind 异常解决办法 java.net.SocketException: Unrecognized Window ...
- System.Net.Sockets.Socket SendAsync System.ObjectDisposedException: Cannot access a disposed object.
发生未处理的域异常! System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net ...
- Socket Programming in C#--Multiple Sockets
Now lets say you have two sockets connecting to either two different servers or same server (which i ...
- ava.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (解决思路)
当我们在启动tomcat服务的时候报错信息:java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bin 分析:从错 ...
- Unrecognized Windows Sockets error: 0: JVM_Bind
Unrecognized Windows Sockets error: 0: JVM_Bind [转帖]今天很是奇怪,在运行服务器端的时候,经常遇到这个异常: java.net.SocketExcep ...
- weblogic sockets 和 thread 问题解决
原创文章,转载须注明出处. 这个问题网上很多答案,可惜没一个能解决.后来发现是weblogic 必须适配JDK 版本. 一般会报这个错误,There are: 5 active sockets, bu ...
随机推荐
- hdu 5338 ZZX and Permutations (贪心+线段树+二分)
ZZX and Permutations Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/O ...
- POJ - 3233 Matrix Power Series (矩阵等比二分求和)
Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + - + Ak. ...
- 【转载】VS工具使用——代码图
代码图: 心想,反正也调不出来,就试试这个东西吧,一打开,就认识到自己发现了一个新大陆:这个代码图可以让我们对一个工程文件有大体的了解,即函数的调用关系等.它是一个VS2013自带工具生成函数 ...
- uva 10806 Dijkstra, Dijkstra. (最小费最大流)
uva 10806 Dijkstra, Dijkstra. 题目大意:你和你的伙伴想要越狱.你的伙伴先去探路,等你的伙伴到火车站后,他会打电话给你(电话是藏在蛋糕里带进来的),然后你就能够跑去火车站了 ...
- 程序员笔记|如何编写高性能的Java代码
一.并发 Unable to create new native thread …… 问题1:Java中创建一个线程消耗多少内存? 每个线程有独自的栈内存,共享堆内存 问题2:一台机器可以创建多少线程 ...
- Linux环境下如何查找哪个线程使用CPU最长
top -H -p pid 查看端口是否被占用: netstat -apn|grep 80
- linux输入子系统(6)-input子系统介绍及结构图
注:本系列转自: http://www.ourunix.org/post/290.html input子系统介绍 输入设备(如按键,键盘,触摸屏,鼠标,蜂鸣器等)是典型的字符设备,其一 ...
- Yarn调度器负载模拟器——Yarn Scheduler Load Simulator (SLS)
一.概述: Yarn调度器有很多实现,如Fifo, Capacity和Fair schedulers等.与其同一时候,正在进行一些优化措施来提高调度器在不同负载和工作场景下的性能.每一个调度器都有自己 ...
- UVA - 12338 Anti-Rhyme Pairs 二分+hash
题目链接:传送门 题意: 给你n个串 问你任意两个串的最大公共前缀长度是多少 题解: 二分+hash 思路很明显,我最近用来写hash 很鸡肋 #include<bits/stdc++.h> ...
- nlp_tool
http://www.afenxi.com/post/9700 11款开放中文分词引擎大比拼 附录评测数据地址http://bosonnlp.com/dev/resource 各家分词系统链接地址Bo ...