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 ...
随机推荐
- linux系统之shell编程-正則表達式
shell编程正則表達式: 1:元字符 [ ] . * ? + ( ) | { } ^ $ 2 : [a-z0-9] 表示匹配随意数字和字母的一个 3 : [^a-z] ...
- 字符串类型ip与数值型ip地址相互转换
/** * 返回Integer类型的ip地址 * @return */ private static Integer ipToInt(){ String ip="192.168.1.201& ...
- 传奇的诞生,PHP三位创始人简介
PHP到现在为止已经诞生12年了.在这期间它经过不断改善,已经成为Web开发最重要的语言之一.PHP能有今天这样的成就,它的3位创始人(Rasmus Lerdorf.Zeev Suraski和Andi ...
- python处理blog文件数据
以下是Python数据处理的题目说明与要求: The attachment is a log file used to show running status of set-top-box, and ...
- UBUNTU安装PHP,即所谓得LAMP
Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组经常使用来搭建动态站点或者server的开源软件,本身都是各自独立的程序,可是由于常被放在一起使用.拥有了越来越 ...
- 12.怎样自学Struts2发送邮件和验证补充[视频]
12.怎样自学Struts2发送邮件和验证补充[视频] 之前写了一篇"打算做一个视频教程探讨怎样自学计算机相关的技术",优酷上传不了,仅仅好传到百度云上: http://pan.b ...
- reviews of learn python3 the hard way
Almost every time,I try my best to write a long review of the book I have read. But this time I want ...
- 有奖试读&征文——我们在互联网上奋斗的故事 获奖名单发布
互联网是一个年轻的行业,同一时候也是一个推陈出新.不断进化的行业. 中国互联网行业在近期的十五年里.以如何的方式在"进化".我相信非常多奋斗在互联网战线上的你们最深有感触.读一读& ...
- Latex 5: LaTeX资料下载
转: LaTeX资料下载 最全latex资料下载 LaTeX命令速查手册1
- 一个简单的servlet
1.创建一个自己的servlet文件,继承HttpServlet MyServlet.java package com.jmu.ccjoin.controller; import java.io.IO ...