浙大计算机研究生保研复试上机考试-2011年 
贪心:
注意:输入输出用scanf  printf 可以加快速度,用cin WA
 #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的更多相关文章

  1. PAT1037:Magic Coupon

    1037. Magic Coupon (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The magi ...

  2. 1037 Magic Coupon (25 分)

    1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an i ...

  3. PAT 1037 Magic Coupon[dp]

    1037 Magic Coupon(25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an in ...

  4. HDU 1153 magic bitstrings(读题+)

    hdu 1153 magic bitstrings 题目大意 一个质数p,现在让你求一个p-1长度的“01魔法串”.关于这个魔法串是这么定义的:     我们现在把这个串经过一段处理变成一个长宽均为p ...

  5. PAT 甲级 1037 Magic Coupon (25 分) (较简单,贪心)

    1037 Magic Coupon (25 分)   The magic shop in Mars is offering some magic coupons. Each coupon has an ...

  6. PAT_A1037#Magic Coupon

    Source: PAT A1037 Magic Coupon (25 分) Description: The magic shop in Mars is offering some magic cou ...

  7. HDU 2274 Magic WisKey

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2274 Magic WisKey Time Limit: 2000/1000 MS (Java/Othe ...

  8. hdu 4605 Magic Ball Game

    http://acm.hdu.edu.cn/showproblem.php?pid=4605 可以离线求解 把所以可能出现的 magic ball  放在一个数组里(去重),从小到大排列 先不考虑特殊 ...

  9. [搜索] hdu 4016 Magic Bitwise And Operation

    主题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4016 Magic Bitwise And Operation Time Limit: 6000/30 ...

随机推荐

  1. java状态模式

    核心思想就是:当对象的状态改变时,同时改变其行为,很好理解!就拿QQ来说,有几种状态,在线.隐身.忙碌等,每个状态对应不同的操作,而且你的好友也能看到你的状态,所以,状态模式就两点:1.可以通过改变状 ...

  2. C#和JAVA 访问修饰符

    JAVA ----------------------------------------------- 访问修饰符        描述 ------------------------------- ...

  3. what eats up the performance in the interior scene?

    - baseline (7w rps/core) - switch from large accelerator to regular accelerator (9w rps/core) - repl ...

  4. SPOJ distinct subtrings

    题目链接:戳我 后缀自动机模板? 求不同的子串数量. 直接\(\sum t[i].len-t[t[i].ff].len\)即可 代码如下: #include<iostream> #incl ...

  5. Mysql内置功能《一》流程控制

    delimiter // CREATE PROCEDURE proc_if () BEGIN declare i int default 0; if i = 1 THEN SELECT 1; ELSE ...

  6. day10学python socket用户交互+MD5加密

    socket用户交互+MD5加密 利用socket从client传输文件指令于server 再返还字节大小与内容 socketserver的使用(重要) 注意: ##client.recv(1024) ...

  7. 2018版OCP考试052最新题库及答案-35题

    35.Your database is using Automatic Memory Management. Which two SGA components must be managed manu ...

  8. 微信小程序遇到的问题与解决

    1.微信开发工具报错 400 (Bad Request) 解决方法: 注:因为开发工具升级 content-type的写法变了 如下代码: header:{     "Content-Typ ...

  9. “全栈2019”Java第六十五章:接口与默认方法详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  10. VMware虚拟机中如何配置静态IP

    我们首先说一下VMware的几个虚拟设备 VMnet0:用于虚拟桥接网络下的虚拟交换机 VMnet1:用于虚拟Host-Only网络下的虚拟交换机 VMnet8:用于虚拟NAT网络下的虚拟交换机 VM ...