浙大计算机研究生保研复试上机考试-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. [LeetCode 题解]: palindromes

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  2. django drf 初探serializer

    1.定义Model对应的serializer from rest_framework import serializers class GoodsSerializer(serializers.Seri ...

  3. select2 模糊查询远程数据

    详细:http://www.cnblogs.com/linJie1930906722/p/6060370.html $("#name").select2({ language: & ...

  4. SprngBoot对静态资源的映射

    $.对前端js类库和框架的引用 使用webjars打包成jar的形式进行引用 webjars地址:https://www.webjars.org/; 选择使用版本-- >   选择管理方式--& ...

  5. c++ inline使函数实现可以在头文件中,避免多重定义错误

    作者:Jon Lee链接:https://www.zhihu.com/question/53082910/answer/133612920来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业 ...

  6. python---Numpy模块中数组运算的常用代码示例

    import numpy as np # Numpy数组操作 print('========访问列表元素, 切片,赋值===========') arr = np.array([2., 6., 5., ...

  7. “全栈2019”Java第七十三章:外部类里多个静态非静态内部类详解

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

  8. API自动化测试 Soap UI工具介绍

    一.   建立测试用例 (一)   基本概念 soapUI 中工程的层次结构 项目名称:位于最上层 (BookStoreTest),项目可以包含多个服务的定义. REST 服务定义:服务其实是对多个 ...

  9. [Swift实际操作]八、实用进阶-(4)通过protocol在两个对象中进行消息传递

    本文将演示如何借助协议,实现视图控制器对象和其内部的自定义视图对象之间的数据传递. 首先创建一个自定义视图对象.在项目名称文件夹点击鼠标右键New File ->Cocoa Touch Clas ...

  10. Objective-C适用C数学函数 <math.h>

    在实际工作中有些程序不可避免的需要使用数学函数进行计算,比如地图程序的地理坐标到地图坐标的变换.Objective-C做为ANSI C的扩展,使用C标准库头文件<math.h>中定义的数学 ...