(hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C
题目链接:http://acm.hzau.edu.cn/problem.php?id=18
题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i]*k*k(k表示取的数量),给你m表示最少取m个物品。然后让你求取m个的最小的价值和。
一个物品的价值是b[i] , 两个物品的价值是b[i] * 3 + b[i] ...
所以每个物品的价值是b[i] , b[i] * 3 , b[i] * 5 , b[i] * 7 ...
每个物品数量a[i]不超过100,所以总共不超过1e5个。所有的物品价值存到数组中,sort一下取前m个即可。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
LL cost[] , a[] , b[];
int main()
{
int n , m;
while(~scanf("%d %d" , &n , &m)) {
for(int i = ; i <= n ; ++i) {
scanf("%lld" , a + i);
a[i] = min(a[i] , (LL)m);
}
int cnt = ;
for(int i = ; i <= n ; ++i) {
scanf("%lld" , b + i);
for(int j = ; j <= a[i] ; ++j)
cost[cnt++] = (LL)( * j - ) * b[i];
}
sort(cost , cost + cnt);
LL sum = ;
for(int i = ; i < m ; ++i) {
sum += cost[i];
}
printf("%lld\n" , sum);
}
}
(hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C的更多相关文章
- 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列
Problem G: Array C Time Limit: 1 Sec Memory Limit: 128 MB Description Giving two integers and and ...
- [HZAU]华中农业大学第四届程序设计大赛网络同步赛
听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...
- 华中农业大学第四届程序设计大赛网络同步赛 J
Problem J: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1766 Solved: 299[Subm ...
- 华中农业大学第四届程序设计大赛网络同步赛 I
Problem I: Catching Dogs Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1130 Solved: 292[Submit][St ...
- 华中农业大学第四届程序设计大赛网络同步赛-1020: Arithmetic Sequence,题挺好的,考思路;
1020: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MB Submit: ->打开链接<- Descriptio ...
- 华中农业大学第五届程序设计大赛网络同步赛-G
G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...
- 华中农业大学第五届程序设计大赛网络同步赛-L
L.Happiness Chicken brother is very happy today, because he attained N pieces of biscuits whose tast ...
- 华中农业大学第五届程序设计大赛网络同步赛-K
K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...
- 华中农业大学第五届程序设计大赛网络同步赛-D
Problem D: GCD Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 179 Solved: 25[Submit][Status][Web B ...
随机推荐
- HDU 2586 + HDU 4912 最近公共祖先
先给个LCA模板 HDU 1330(LCA模板) #include <cstdio> #include <cstring> #define N 40005 struct Edg ...
- bzoj2326: [HNOI2011]数学作业
矩阵快速幂,分1-9,10-99...看黄学长的代码理解...然而他直接把答案保存在最后一行(没有说明...好吧应该是我智障这都不知道... #include<cstdio> #inclu ...
- 好用的工具之一 ---- Sublime Text
官网地址和详细解释:http://www.sublimetext.com/ 异次元的一些更详细的个人体验细节:http://www.iplaysoft.com/sublimetext.html
- hdu 4674 Trip Advisor(缩点+倍增lca)
花了一天半的时间,才把这道题ac= = 确实是道好题,好久没敲这么长的code了,尤其是最后的判定,各种销魂啊~ 题目中给出的条件最值得关注的就是:每个点最多只能在一个环内->原图是由一个个边连 ...
- 【iOS-Cocos2d游戏开发之四】独自收集Cocos2d提供的字体!共57种(有对照的字体图)
本站文章均为李华明Himi原创,转载务必在明显处注明:(作者新浪微博:@李华明Himi) 转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/iphone-c ...
- javascript 命名空间的实例应用
/** * 创建全局对象MYAPP * @module MYAPP * @title MYAPP Global */ var MYAPP = MYAPP || {}; /** * 返回指定的命名空间, ...
- 【 D3.js 视频系列 】 飞速入门
本教程共包含 6 个视频,目的是为了帮助初学者快速入门,以便阅读本站其他文章. 本教程的名称为"飞速入门",是为初学者准备的,其中包括了 D3 开发中最基础的知识.对 D3 掌握得 ...
- Linux编译安装Darwin Streaming Server 6.0.3。。。
目前主流的流媒体服务器有微软的windows media server.RealNetworks的Helixserver和苹果公司的Darwin Streaming Server. 微软的window ...
- 【转】一致性hash算法(consistent hashing)
consistent hashing 算法早在 1997 年就在论文 Consistent hashing and random trees 中被提出,目前在 cache 系统中应用越来越广泛: 1 ...
- 1045 整数礼物 c语言
描述 Na 给准备送给ZZ两个整数,a, b,他还计算了这两个整数的平均值c,碰巧c也是整数. 但是Na 突然把b给弄丢了,你要帮助Na通过a, c计算出来b的值. 输入 输入为一行,两个用空格隔开的 ...