CF934A A Compatible Pair
1 second
256 megabytes
standard input
standard output
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming.
Little Tommy has n lanterns and Big Banban has m lanterns. Tommy's lanterns have brightness a1, a2, ..., an, and Banban's have brightness b1, b2, ..., bm respectively.
Tommy intends to hide one of his lanterns, then Banban picks one of Tommy's non-hidden lanterns and one of his own lanterns to form a pair. The pair's brightness will be the product of the brightness of two lanterns.
Tommy wants to make the product as small as possible, while Banban tries to make it as large as possible.
You are asked to find the brightness of the chosen pair if both of them choose optimally.
The first line contains two space-separated integers n and m (2 ≤ n, m ≤ 50).
The second line contains n space-separated integers a1, a2, ..., an.
The third line contains m space-separated integers b1, b2, ..., bm.
All the integers range from - 109 to 109.
Print a single integer — the brightness of the chosen pair.
2 2
20 18
2 14
252
5 3
-1 0 1 2 3
-1 0 1
2
In the first example, Tommy will hide 20 and Banban will choose 18 from Tommy and 14 from himself.
In the second example, Tommy will hide 3 and Banban will choose 2 from Tommy and 1 from himself.
Tommy是想进办法要使值最小所以肯定会隐藏使值最大的在他手上的数,Banban是想进办法使值最大,但是Tommy隐藏了他手中可以使值最大的数,所以最后得到的结果肯定是第二大的数。
做题的时候没有想到。。。
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 10000010
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
int main() {
int n,m;
while( cin >> n >> m ) {
ll a[],b[];
for( int i = ; i < n; i ++ ) {
cin >> a[i];
b[i] = -2e18;
}
for( int j = ; j < m; j ++ ) {
int t;
cin >> t;
for( int i = ; i < n; i ++ ) {
b[i] = max( b[i], a[i]*t );
}
}
sort(b,b+n);
cout << b[n-] << endl;
}
return ;
}
CF934A A Compatible Pair的更多相关文章
- CF934A A Compatible Pair 题解
Content 有两个数列 \(A\) 和 \(B\),\(A\) 数列里面有 \(n\) 个元素,\(B\) 数列里面有 \(m\) 个元素,现在请从 \(A\) 数列中删除一个数,使得 \(A\) ...
- Codeforces 934.A A Compatible Pair
A. A Compatible Pair time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #462 (Div. 2) A Compatible Pair
A. A Compatible Pair time limit per test1 second memory limit per test256 megabytes Problem Descript ...
- Codeforces 934 A.Compatible Pair
http://codeforces.com/contest/934 A. A Compatible Pair time limit per test 1 second memory limit p ...
- 题解 CF934A 【A Compatible Pair】 ——贪心
题意: 给定两个数列 \(A\) . \(B\) ,元素个数分别为 \(n\) , \(m\) \((2 \le n,m \le 50)\) .数列中所有元素大小均在 \(-10^{9}\) 到 \( ...
- A - A Compatible Pair
Problem description Nian is a monster which lives deep in the oceans. Once a year, it shows up on th ...
- A Compatible Pair
Description “年”是一个生活在海洋深处的怪物.每年,它都出现在陆地上,吞噬牲畜甚至是人.为了让怪物离开,人们用红色,光线和爆炸的声音填满他们的村庄,所有这些都吓跑了怪物. 小汤米有 n ...
- A - A Compatible Pair-biaobiao88
A - A Compatible Pair Nian is a monster which lives deep in the oceans. Once a year, it shows up on ...
- pair queue____多源图广搜
.简介 class pair ,中文译为对组,可以将两个值视为一个单元.对于map和multimap,就是用pairs来管理value/key的成对元素.任何函数需要回传两个值,也需要pair. 该函 ...
随机推荐
- 使用阿里云oss
写这篇博文的原因是公司有个项目需要用到阿里云来存放用户头像文件.后期软件安装版本也可能需要存进去,然后折腾了两天终于摸熟了一点皮毛,在这里给大家简单介绍下. 一.初识对象存储oss 1.进入阿里云控制 ...
- 【0801 | Day 6】Python基础(四)
Part 13 流程控制之while循环 一.语法 while 条件 code 1 code 2 code 3 ... while True: print('*1'*100) print('*2' ...
- 带你剖析WebGis的世界奥秘----瓦片式加载地图
WebGIS应用程序的页面能够通过HTML.JSP.ASP或任何任何类型的Web页文件构成,其特殊之处在于,它的请求提交的方法并不是通过常用的 "超链接"形式,而是使用鼠标与Web ...
- ubuntu-18.10 虚拟机 配置网络环境
查询主机系统ip 使用virtualbox 设置网络模式为桥接模式 设置静态 ip 与网关 关闭防火墙 sudo ufw disable
- Python模块之pexpect
一.pexpect模块介绍 Pexpect使Python成为控制其他应用程序的更好工具.可以理解为Linux下的expect的Python封装,通过pexpect我们可以实现对ssh,ftp,pass ...
- 四、Ansible的Galaxy包管理器
一.什么是Ansible Galaxy? Ansible Galaxy是Ansible的第三方插件管理和安装工具,其实就是包管理软件.作用类似于Ubuntu的apt,Centos的yum,Python ...
- 自定义genericUDF demo
package cn.com.dtmobile.hiveUdf; import org.apache.hadoop.hive.ql.exec.UDFArgumentException; import ...
- CSS动效集锦,视觉魔法的碰撞与融合(一)
前言 在本文中我讲述了7种CSS的动效,它们也许看起来并不惊艳,但是我认为却足够传达本文的理念:编写一些特殊的CSS样式的时候需要不拘于常理,要用特殊的认识角度看待标签和样式属性,从而用「绕个弯」的方 ...
- Django上线部署之IIS
环境: 1.Windows Server 2016 Datacenter 64位 2.SQL Server 2016 Enterprise 64位 3.Python 3.6.0 64位 4.admin ...
- LoRaWAN_stack移植笔记(七)_数据包的接收发送
以下的代码适用于LoRa sx1276点对点的通讯,纯粹的考虑在非发射模式下即为接收模式 配置sx1276的射频参数,并且切换到接收模式 //bandwidth [0:125 1:250 2:500] ...