Jingze is a big figure in California State University for his stubbornness. Because of his new failure in the last CET-4, he has decided not to solve problems with English discription any more. In yesterday‘s warm-up contest,he protested to the organizing committee for the appearance of long English discription and threatened to eat all the bread of the contestants during coding. Undoubtedly, this behavior will seriously affect the entire competition. In order to help him get rid of English phobias, good-hearted seniors decided to help him regain his confidence with simple English problems. This problem is a gift that we gave to all contestants who are in the same boat with him.

In today's campus coding match, the contestants brought a variety of bread and milk, and each kind of bread and milk has its own deliciousness. Because Jingze can't just eat bread, he will also wipe out a carton of milk when eating a loaf of bread. If only bread or only milk leaves to have, his appetite will be zero. Since bread and milk are amazing lunch partners, different combinations bring different tastes. Everyone knows the deliciousness of some combination is defined to be its product. Of course the maximum sum of deliciousness is desired for Jingze while the minimum for us, although in both cases we seem to be disadvantaged.

In fact, the Lunch War will never happen and the following gif may be your live picture of today's early reading time and closing ceremony.

Input

There are at most 20 test case.

For each test cases, you are given the number of kinds of bread and milk, N, M for each and 1 ≤ N, M ≤ 105.

In the following two lines are N + M positive integers denoting the deliciousness for each kind of bread and milk.

The deliciousness is guaranteed within 100.

Output

Two integers per line for each test: The maximum and minimum sum of deliciousness for Jingze and us.

Sample Input

1 4
23
67 50 25 2 10 6
95 30 2 18 96 6 5 52 99 89
24 6 83 53 67 17

Sample Output

1541 46
22884 2073 em 就是求上下组合起来乘积和最大值、最小值。
最大值很好说就是最大乘最大。
最小值的话,大值乘小值就是了
 #include<iostream>
#include<cstdio>
#include<algorithm> using namespace std;
const int maxn = ;
int a[maxn];
int b[maxn]; int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
for(int i=; i<n; ++i)
{
scanf("%d",&a[i]);
}
for(int i=; i<m; i++)
{
scanf("%d",&b[i]);
}
sort(a,a+n);
sort(b,b+m);
int minn = min(n,m);
int max_sun = , min_sum = ;
for(int i=; i<minn; ++i)
{
max_sun += a[n-i-]*b[m-i-];
min_sum += a[i]*b[minn-i-];
}
printf("%d %d\n",max_sun,min_sum);
}
}

Lunch War with the Donkey CSU - 2084的更多相关文章

  1. CSU - 2031 Barareh on Fire (两层bfs)

    传送门: http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2031 Description The Barareh village is on f ...

  2. jar\war\SpringBoot加载包内外资源的方式,告别FileNotFoundException吧

    工作中常常会用到文件加载,然后又经常忘记,印象不深,没有系统性研究过,从最初的war包项目到现在的springboot项目,从加载外部文件到加载自身jar包内文件,也发生了许多变化,这里开一贴,作为自 ...

  3. 用Maven部署war包到远程Tomcat服务器

    过去我们发布一个Java Web程序通常的做法就是把它打成一个war包,然后用SSH这样的工具把它上传到服务器,并放到相应的目录里,让Tomcat自动去解包,完成部署. 很显然,这样做不够方便,且我们 ...

  4. 多War项目中静态文件的共享方案

    [原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 在互联网产品中,一般会有多个项目(Jar.WAR)组成一个产品线.这些WAR项目,因为使用相同的前端架构(jQuery.easyui等) ...

  5. war 文件打包技巧

    1.首先是工具比如Eclipse很方便了. 2.用winrar之类的工具,把web-info目录,及跟它同级的所有目录及文件,打包成 zip文件就行了,然后把扩展名改成war! 3 Jar命令: 假定 ...

  6. Windows 安装JRuby 生成 war 到 tomcat 运行

    Windows安装JRuby Rails 直接下载 JRuby,不装 Ruby. http://jruby.org/download 该安装包可以配好环境变量 %JRUBY_HOME% 等 安装 bu ...

  7. war项目在tomcat上面部署

    1.war包放到webapps根目录下. 2.修改tomcat目录下的conf文件夹里面的的server.xml,在<Host></Host>之间加入: <Context ...

  8. Ansible-playbook批量部署,更新war脚本,可以再完善----后续再update

    - name: install tomcat admin hosts: all sudo: True vars: war_file: /root/test.war tomcat_root: /data ...

  9. 基于Java的打包jar、war、ear包的作用与区别详解

      本篇文章,小编为大家介绍,基于Java的打包jar.war.ear包的作用与区别详解.需要的朋友参考下   以最终客户的角度来看,JAR文件就是一种封装,他们不需要知道jar文件中有多少个.cla ...

随机推荐

  1. liunx tomcat 运行模式apr

    tomcat运行模式一共三种:bio.nio.apr 网上对这三种运行模式的解释外: bio运行模式:阻塞式I/O操作,表示Tomcat使用的是传统的Java I/O操作(即java.io包及其子包) ...

  2. oracle 在C# 中调用oracle的数据库时,出现引用库和当前客户端不兼容的问题解决方案

    oracle 在C# 中调用oracle的数据库时,出现引用库和当前客户端不兼容的问题解决方案 解决方案 1.直接引用  Oracle.ManagedDataAccess.Client.dll动态库即 ...

  3. 在 Confluence 中启用 HTTP 响应压缩

    Confluence 能够支持 HTTP 的 GZip 传输编码.这个意味着 Confluence 将可以把数据压缩后传输给用户,这种配置能够针对不稳定的互联网状态下的传输速度缓慢和不稳定并且能够降低 ...

  4. Confluence 6 导入一个 Confluence 站点

    有下面 2 种类方法可以导入一个站点 - 通过上传一个文件或者从你 Confluence 服务器上读取一个目录.上传文件仅仅是针对一个小站点的情况.为了取得最好的导入结果,我们推荐你从服务器上的目录上 ...

  5. 获取checkbox勾选的id

    需求描述:做批量删除或者批量修改的时候需要获得多个id,根据checkbox勾选来获取对应的d 两种方法: //html代码<table id="table1"> &l ...

  6. time与datetime模块

    在python中,通常用下面几种方式来表示时间: 时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量. 格式化的时间字符串(format s ...

  7. python面向对象三大特性之封装

    一. 概述 定义:隐藏对象的属性和实现细节,仅对外提供公共访问方式 封装的原则:把不需要对外提供的内容都隐藏起来,提供公共的方法访问这些隐藏属性 二.封装手段 使用双下划线将属性和方法隐藏起来 cla ...

  8. json如果不在pom中添加依赖会抛出500异常

    所以必须添加以下依赖: <!--jackson相关依赖--><!-- https://mvnrepository.com/artifact/com.fasterxml.jackson ...

  9. Python - 去除list中的空字符

    list1 = ['122', '2333', '3444', '', '', None] a = list(filter(None, list1)) # 只能过滤空字符和None print(a) ...

  10. java线程间的通信方式

    1.同步 synchronized 2.轮询 while   volatile 3.wait/notify机制 syncrhoized加锁的线程的Object类的wait()/notify()/not ...