https://code.google.com/codejam/contest/32016/dashboard

题目大意:

GCJ(google code jam)上的水题。下周二有比赛,来熟悉熟悉。

有两个向量V1=(x1,x2……xn)和v2=(y1,y2……yn),允许任意交换v1和v2各自的分量顺序,请计算v1和v2的内积x1y1+……xnyn的最小值

思路:

不同于OJ的地方在于有大和小的数据之分,且都是用文件来完成。需要自己下载测试数据,输出的数据用文件保存并且上传。

主函数最前面加个

freopen("e:\\input.in","r",stdin);   

    freopen("e:\\out.out","w",stdout);

即可。

第一句是输入,第二句是输出。

直接排个序,第一个从小到大,第二个从大到小,然后按顺序乘即可。

#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=800+10;
typedef long long LL;
LL a[MAXN],b[MAXN];
int main()
{
freopen("e:\\input.in","r",stdin);
freopen("e:\\out.out","w",stdout);
int T;
scanf("%d",&T);
for(int kase=1;kase<=T;kase++)
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%lld",&a[i]);
for(int i=0;i<n;i++)
scanf("%lld",&b[i]); sort(a,a+n);
sort(b,b+n);
LL ans=0;
for(int i=0;i<n;i++)
ans+=a[i]*b[n-i-1];
printf("Case #%d: %lld\n",kase,ans);
}
return 0;
}

GCJ 2008 Round 1A Minimum Scalar Product的更多相关文章

  1. GCJ 2008 Round 1A Minimum Scalar Product( 水 )

    链接:传送门 题意:给两个向量 v1 = { x1 , x2 , x3 , x4 .... } , v2 = { y1 , y2 , y3 , y4 ...... } 允许任意交换 v1 和 v2 各 ...

  2. [Google Code Jam (Round 1A 2008) ] A. Minimum Scalar Product

    Problem A. Minimum Scalar Product   This contest is open for practice. You can try every problem as ...

  3. codejam环境熟悉—Minimum Scalar Product

    今天准备熟悉一下codejam的在线编程,为google的笔试做准备,因此按照codejam上对新手的建议,先用了一个简单的题目来弄清楚流程.记录一下需要注意的地方.   1.输入输出 输入输出重定位 ...

  4. GCJ——Minimum Scalar Product(2008 Round1 AA)

    题意: 给定两组各n个数,可任意调整同一组数之中数字的顺序,求 sum xi*yi i=1..n的最小值. Small: n<=8 abs xy,yi<=1000 Large: n< ...

  5. 2008 Round 1A C Numbers (矩阵快速幂)

    题目描述: 请输出(3+√5)^n整数部分最后3位.如果结果不超过2位,请补足前导0. 分析: 我们最容易想到的方法肯定是直接计算这个表达式的值,但是这样的精度是不够的.朴素的算法没有办法得到答案.但 ...

  6. Google Code Jam 2008 Round 1A C Numbers(矩阵快速幂+化简方程,好题)

    Problem C. Numbers This contest is open for practice. You can try every problem as many times as you ...

  7. GCJ:2008 Round1AA-Minimum Scalar Product(有序数组倒序乘积和最小)

    题目链接:https://code.google.com/codejam/contest/32016/dashboard#s=p0 Minimum Scalar Product This contes ...

  8. [UCSD白板题] Minimum Dot Product

    Problem Introduction The dot product of two sequences \(a_1,a_2,\cdots,a_n\) and \(b_1,b_2,\cdots,b_ ...

  9. [Google Codejam] Round 1A 2016 - The Last Word

    [Problem Description] Problem On the game show The Last Word, the host begins a round by showing the ...

随机推荐

  1. Flex与Java通信之HttpService

    flashbuilder4.6.myeclipse10 参考:http://www.cnblogs.com/lovemoon714/archive/2012/05/25/2517684.html 1. ...

  2. Maintaining processor resources during architectural events

    In one embodiment of the present invention, a method includes switching between a first address spac ...

  3. RvmTranslator6.3 is released

    RvmTranslator6.3 is released eryar@163.com RvmTranslator can translate the RVM file exported by AVEV ...

  4. vue 引入第三方字体包

    1.创建 style_css 文件夹,在当前文件夹下 新建 index.css  和  引入字体包. 2. 在build 目录下,设置 webpack.base.cong.js ,  在module ...

  5. Http1.1和http2.0

    HTTP2.0 最近在读一本书叫<web性能权威指南>谷歌公司高性能团队核心成员的权威之作. 一直听说HTTP2.0,对此也仅仅是耳闻,没有具体研读过,这次正好有两个篇章,分别讲HTTP1 ...

  6. 3.索引与string进行映射实现高效查找

    #include <iostream> #include <typeindex>//类型索引 #include <unordered_map>//红黑树 #incl ...

  7. Kali的源得数字验证问题

    装上之后第一件事就是执行apt-get update && apt-get upgrade,结果却出现了这样的错误 我添加的是中科大的更新源,在浏览器中是可以正常打开的: deb ht ...

  8. Java设计模式23种(搞笑版) (转)

        昨天做了一下支付宝的笔试题目被打击了,大量的逻辑推理和数学规律运算题目,其中还有问道Java设计模式的题目,一点都不知道,今天看到一份不错的介绍,非常好理解,作者是谁我没有办法考证,但是所有权 ...

  9. Duboo入门示例(Idea开发环境)

    在学习Dubbo分布式框架时的官方入门例子,很有代表性.简单清晰. 有关Dubbo的概念.概述和简单的配置文件,可以看官方文档的简述 会很快对Duboo有个整体的概念. 准备工作: 下载示例,点击这里 ...

  10. 洛谷 P1506 拯救oibh总部

    P1506 拯救oibh总部 题目背景 oibh总部突然被水淹没了!现在需要你的救援…… 题目描述 oibh被突来的洪水淹没了>.<还好oibh总部有在某些重要的地方起一些围墙,用*号表示 ...