hdu 3794 Magic Coupon
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
#define MAX 1000000
__int64 c[MAX+];
__int64 p[MAX+];
__int64 nc,np;
int main()
{
//freopen("INPUT.txt", "r", stdin);
while(cin>>nc&&nc>=){
__int64 i=;
for(;i<nc;i++){
scanf("%I64d",&c[i]);
}
cin>>np;
i=;
for(;i<np;i++){
scanf("%I64d",&p[i]);
}
sort(c,c+nc);
sort(p,p+np);
i=;
__int64 sum=;
while(c[i]<&&p[i]<&&i<nc&&i<np){
sum+=c[i]*p[i];
i++;
}
__int64 cc=nc-;
__int64 pp=np-;
while(c[cc]>&&p[pp]>&&cc>=&&pp>=){
sum+=c[cc]*p[pp];
cc--;
pp--;
}
printf("%I64d\n",sum);
}
return ;
}
hdu 3794 Magic Coupon的更多相关文章
- PAT1037:Magic Coupon
1037. Magic Coupon (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The magi ...
- 1037 Magic Coupon (25 分)
1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an i ...
- PAT 1037 Magic Coupon[dp]
1037 Magic Coupon(25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an in ...
- HDU 1153 magic bitstrings(读题+)
hdu 1153 magic bitstrings 题目大意 一个质数p,现在让你求一个p-1长度的“01魔法串”.关于这个魔法串是这么定义的: 我们现在把这个串经过一段处理变成一个长宽均为p ...
- PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)
1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an ...
- PAT_A1037#Magic Coupon
Source: PAT A1037 Magic Coupon (25 分) Description: The magic shop in Mars is offering some magic cou ...
- HDU 2274 Magic WisKey
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2274 Magic WisKey Time Limit: 2000/1000 MS (Java/Othe ...
- hdu 4605 Magic Ball Game
http://acm.hdu.edu.cn/showproblem.php?pid=4605 可以离线求解 把所以可能出现的 magic ball 放在一个数组里(去重),从小到大排列 先不考虑特殊 ...
- [搜索] hdu 4016 Magic Bitwise And Operation
主题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4016 Magic Bitwise And Operation Time Limit: 6000/30 ...
随机推荐
- winfrom 右下角弹窗(渐渐消失)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Markdown应用样例
Markdown编辑器: https://www.typora.io/ Markdown主题: http://theme.typora.io/ 1.标题 一号标题 三号标题 六号标题 2.超链接 Cm ...
- c#设计模式系类:亨元模式
一.引言 在软件开发过程中,如果我们需要重复使用某个对象的时候,如果我们重复地使用new创建这个对象的话,这样我们在内存就需要多次去申请内存空间了,这样可能出现内存使用越来越多的情况,这样的问题是非常 ...
- EF:无法检查模型兼容性,因为数据库不包含模型元数据。
Model compatibility cannot be checked because the database does not contain model metadata. Model ...
- 2015-9-13 NOIP模拟赛解题报告(by hzwer)
小奇挖矿 「题目背景」 小奇要开采一些矿物,它驾驶着一台带有钻头(初始能力值w)的飞船,按既定路线依次飞过喵星系的n个星球. 「问题描述」 星球分为2类:资源型和维修型. 1.资源型:含矿物质量a[i ...
- 在eclipse上的hdfs的文件操作
参考:http://dblab.xmu.edu.cn/blog/hadoop-build-project-using-eclipse/?tdsourcetag=s_pcqq_aiomsg: http ...
- UWA发布 | 2017 Unity手游体检蓝皮书 — ARPG篇
报告目录: 一.ARPG手游总体性能开销分析 二.ARPG手游CPU模块性能开销分析 三.ARPG手游内存模块性能开销分析 四.ARPG手游资源管理分析 五.UWA对于ARPG手游研发团队的建议 一. ...
- js计算机样式window.getComputedStyle(ele,null)与
一.getComputedStyle兼容IE8以上,范户籍的计算样式的值都是绝对值,没有相对单位(如:width:10em; 它打印出来是160px) window.getComputedStyle( ...
- js项目
https://bbs.csdn.net/topics/320029234 文本实现悬挂缩进 牛逼牛逼 这是真的牛逼 p:first-letter { margin-left: -2e ...
- NOI2017 酱油记
侥幸混进市队让我晚退役了几个月..不过终究还是退役了呢..这应该是最后一篇游记了吧.. 考前半个月都在安徽集训..然后发现所有人都停课集训..只有我暑假了开始.. 反正上课各种听不懂..各种被大佬虐. ...