Lunch War with the Donkey CSU - 2084
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的更多相关文章
- CSU - 2031 Barareh on Fire (两层bfs)
传送门: http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2031 Description The Barareh village is on f ...
- jar\war\SpringBoot加载包内外资源的方式,告别FileNotFoundException吧
工作中常常会用到文件加载,然后又经常忘记,印象不深,没有系统性研究过,从最初的war包项目到现在的springboot项目,从加载外部文件到加载自身jar包内文件,也发生了许多变化,这里开一贴,作为自 ...
- 用Maven部署war包到远程Tomcat服务器
过去我们发布一个Java Web程序通常的做法就是把它打成一个war包,然后用SSH这样的工具把它上传到服务器,并放到相应的目录里,让Tomcat自动去解包,完成部署. 很显然,这样做不够方便,且我们 ...
- 多War项目中静态文件的共享方案
[原创申明:文章为原创,欢迎非盈利性转载,但转载必须注明来源] 在互联网产品中,一般会有多个项目(Jar.WAR)组成一个产品线.这些WAR项目,因为使用相同的前端架构(jQuery.easyui等) ...
- war 文件打包技巧
1.首先是工具比如Eclipse很方便了. 2.用winrar之类的工具,把web-info目录,及跟它同级的所有目录及文件,打包成 zip文件就行了,然后把扩展名改成war! 3 Jar命令: 假定 ...
- Windows 安装JRuby 生成 war 到 tomcat 运行
Windows安装JRuby Rails 直接下载 JRuby,不装 Ruby. http://jruby.org/download 该安装包可以配好环境变量 %JRUBY_HOME% 等 安装 bu ...
- war项目在tomcat上面部署
1.war包放到webapps根目录下. 2.修改tomcat目录下的conf文件夹里面的的server.xml,在<Host></Host>之间加入: <Context ...
- Ansible-playbook批量部署,更新war脚本,可以再完善----后续再update
- name: install tomcat admin hosts: all sudo: True vars: war_file: /root/test.war tomcat_root: /data ...
- 基于Java的打包jar、war、ear包的作用与区别详解
本篇文章,小编为大家介绍,基于Java的打包jar.war.ear包的作用与区别详解.需要的朋友参考下 以最终客户的角度来看,JAR文件就是一种封装,他们不需要知道jar文件中有多少个.cla ...
随机推荐
- Confluence 6 创建一个主题
如果你希望创建你自己的主题,你需要写一个 Confluence 插件.请参考我们开发文档中的下面页面 开始使用 插件开发. 请参考开发者指南的页面来 写一个 Confluence 主题. 使用 主题插 ...
- Confluence 6 用户宏最佳实践
这个页面为你在创建用户宏的最佳实践中包含了一些小技巧和建议. 为你的宏添加一个简短的描述 我们鼓励你为你的宏在 模板(Template )添加一个备注的描述,可以参考下面的显示的内容: ## Macr ...
- LeetCode(112):路径总和
Easy! 题目描述: 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和. 说明: 叶子节点是指没有子节点的节点. 示例: 给定如下二叉树,以及 ...
- 新增 修改,对xx名字或者其他属性做校验判断是否存在
需求描述:页面输入完xxName和xx编码,点击提交,根据两项内容做重复校验(就是看看数据库里有木有相同的) 解决思路:把这两个东西作为查询条件去查,查到有记录,提示已存在,就不执行新增或者修改操作. ...
- java易错题----静态方法的调用
class A{ public static String s="A.s"; } class B extends A{ public static String s="B ...
- 在线版区间众数 hzw的代码。。
/* 查询区间众数,要求强制在线 设有T个块 1.众数只可能在大块[L,R]里或者两端[l,L) (R,r]里出现 2.大块的众数只要预处理打表一下即可,复杂度n*T(这样的区间有T*T个) 3.两端 ...
- OrCAD Capture CIS 16.6 修改原理图的页面大小
OrCAD Capture CIS 16.6 打开需要修改的原理图. 菜单:Options > Schematic Page Properties... 看图操作...
- python unittest套件,修改为失败重新执行
#套件,修改为失败重新执行 import time import unittest from unittest.suite import _isnotsuite class Suit(unittest ...
- AI学习吧-公钥私钥、沙箱环境
公钥私钥 公钥.私钥 可以互相解密 应用:数字签名和加密数据 数字签名:使用私钥加密,公钥解密 加密数据:使用公钥加密,私钥解密泄密时:当有人拿走了你的公钥,你可以到CI证书中心,使用你的私钥和公钥办 ...
- Windows Internals 笔记——线程局部存储区
1.由于C/C++运行库是在多线程应用程序出现的许多年前设计的,因此运行库中的大多数函数是为单线程应用程序设计的. 2.当应用程序第一次调用_tcstok_s的时候该函数将传入的字符串地址保存在它自己 ...