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 ...
随机推荐
- Java中的多态方法
public class Main { public void test(Object o) { System.out.println("Object"); } public vo ...
- .NET CORE 2.1 导出excel文件的两种方法
最近在做 MVC 项目的时候遇到项目的导出,下面总结下两种导出到excel 的方法 第一种方法: 将文件写到本地,然后返回这个File 或者返回这个 File 的绝对地址 其中 _hostingE ...
- Commons包详解
Apache Commons包含了很多开源的工具,用于解决平时编程经常会遇到的问题,减少重复劳动.项目地址http://commons.apache.org/ Commons BeanUtils 提供 ...
- Spring各个jar包详解
Spring各jar包详解 spring.jar 是包含有完整发布模块的单个jar 包.但是不包括mock.jar,aspects.jar, spring-portlet.jar, and sprin ...
- Performance profile of a typical interior scene
------------------------------- Num faces: 7000k+ Num lights: 38 Num textures: 79 Textures on disk: ...
- Web Server 在iis上部署webservice基于oracle
在iis上部署webservice基于oracle 常见错误及解决方案: 原因: 先安装.netframework后安装iis造成的: 解决方案: 1.C:\Windows\Microsoft.NET ...
- python: list转字符串
命令: ' '.join(list) 其中,引号中是字符之间的分割符,如“,”,“;”,“\t”等等 如: list = [1, 2, 3, 4, 5] ''.join(list) 结果即为:1234 ...
- day02.4-字典内置方法
字典——dict的定义:test = {"k1":18,2:True,"k3":[11,22,("zi","zai")] ...
- 本地Windows环境下安装MySql
Windows 上安装 MySQL Windows 上安装 MySQL 相对来说会较为简单,你需要在 MySQL 下载中下载 Windows 版本的 MySQL 安装包. Download Link: ...
- AtCoder Grand Contest 031题解
题面 传送门 题解 比赛的之后做完\(AB\)就开始发呆了--简直菜的一笔啊-- \(A - Colorful\ Subsequence\) 如果第\(i\)个字母选,那么它前面任意一个别的字母的选择 ...