『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]-最小内积(第八届北京师范大学程序设计竞赛决赛)
H. 最小内积
64-bit integer IO format: %lld
Java class name: Main
Input
Output
Sample Input
5
1 2 3 4 5
1 0 1 0 1
Sample Output
6
这种拼手速的题只恨自己手速不够快,我们只需把两个相反的排序就好了,一个最大值乘以最小值和才是最小的;
SO:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1000+10;
int a[N],b[N];
int cmp(int a,int b)
{
return a>b;
}
int main()
{
int n,i,sum;
while(~scanf("%d",&n))
{
sum=0;
for(i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
for(i=0; i<n; i++)
scanf("%d",&b[i]);
sort(b,b+n,cmp);//逆序排序;
for(i=0; i<n; i++)
sum+=a[i]*b[i];
printf("%d\n",sum);
}
return 0;
}
『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]-最小内积(第八届北京师范大学程序设计竞赛决赛)的更多相关文章
- 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)
A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]--Codeforces -35D. Animals
D. Animals time limit per test 2 seconds memory limit per test 64 megabytes input input.txt output o ...
- 第十五届北京师范大学程序设计竞赛现场决赛题解&源码(A.思维,C,模拟,水,坑,E,几何,思维,K,字符串处理)
#include <bits/stdc++.h> using namespace std; int main() { int T,n,a,b; while(cin>>T) { ...
- 『PyTorch』第九弹_前馈网络简化写法
『PyTorch』第四弹_通过LeNet初识pytorch神经网络_上 『PyTorch』第四弹_通过LeNet初识pytorch神经网络_下 在前面的例子中,基本上都是将每一层的输出直接作为下一层的 ...
- 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 237C,素数打表,二分查找
C. Primes on Interval time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 236A,虽然很水,但有一个很简单的函数用起来方便
A. Boy or Girl time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]CF-236B. Easy Number Challenge
B. Easy Number Challenge time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- “浪潮杯”第九届山东省ACM大学生程序设计竞赛重现赛 C-Cities
题目描述:There are n cities in Byteland, and the ith city has a value ai. The cost of building a bidirec ...
- “浪潮杯”第九届山东省ACM大学生程序设计竞赛(重现赛)E.sequence(树状数组求逆序对(划掉))
传送门 E.sequence •题意 定义序列 p 中的 "good",只要 i 之前存在 pj < pi,那么,pi就是 "good": 求删除一个数, ...
随机推荐
- oracle 10g standby 设置
##########sample alter system set log_archive_dest_1 = 'LOCATION=USE_DB_RECOVERY_FILE_DEST' scope=bo ...
- [转]ASP.NET MVC Bootstrap极速开发框架
本文转自:http://www.cnblogs.com/smartbooks/p/3814927.html 前言 每次新开发项目都要从头开始设计?有木有一个通用的快速开发框架?并且得是ASP.NET ...
- AJPFX总结方法里的属性
嵌套循环:循环里套循环 假设外循环的循环次数是m次,内循环的循环次数是n次,那么内层循环的循环次数需要 m * n次. Eg:利用for循环语句的嵌套打印出乘法口诀表 class break1 ...
- RabbitMq+Haproxy负载均衡
HAProxy是一个使用C语言编写的自由及开放源代码软件,其提供高可用性.负载均衡,以及基于TCP和HTTP的应用程序代理. HAProxy特别适用于那些负载特大的web站点,这些站点通常又需要会话保 ...
- html语法第 -2
1 <html> 2 <head> 3 <title>这是第一节课网页标题</title> 4 <meta charset="UTF-8 ...
- myeclipse 安装svn(subeclipsesite)插件
(1)到官网下载subeclipsesite,下载最新的版本:http://subclipse.tigris.org/servlets/ProjectDocumentList?folderID=224 ...
- jstat查看JVM的GC情况
jps(Java Virtual Machine Process Status Tool)是JDK 1.5提供的一个显示当前所有java进程pid的命令,简单实用,非常适合在linux/unix平台上 ...
- hdu 2192 MagicBuilding
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
- Zabbix使用外部命令fping处理ICMP ping的请求
Zabbix使用外部命令fping处理ICMP ping的请求,fping不包含在zabbix的发行版本中,需要额外去下载安装fping程序, 安装完毕之后需要在zabinx_server.conf中 ...
- iview 的 Carousel 走马灯 焦点图 不能用 建议换/vue-awesome-swiper
https://www.npmjs.com/package/vue-awesome-swiper