题目链接: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的更多相关文章

  1. 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列

    Problem G: Array C Time Limit: 1 Sec  Memory Limit: 128 MB Description Giving two integers  and  and ...

  2. [HZAU]华中农业大学第四届程序设计大赛网络同步赛

    听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...

  3. 华中农业大学第四届程序设计大赛网络同步赛 J

    Problem J: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1766  Solved: 299[Subm ...

  4. 华中农业大学第四届程序设计大赛网络同步赛 I

    Problem I: Catching Dogs Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1130  Solved: 292[Submit][St ...

  5. 华中农业大学第四届程序设计大赛网络同步赛-1020: Arithmetic Sequence,题挺好的,考思路;

    1020: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MB Submit:  ->打开链接<- Descriptio ...

  6. 华中农业大学第五届程序设计大赛网络同步赛-G

    G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...

  7. 华中农业大学第五届程序设计大赛网络同步赛-L

    L.Happiness Chicken brother is very happy today, because he attained N pieces of biscuits whose tast ...

  8. 华中农业大学第五届程序设计大赛网络同步赛-K

    K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...

  9. 华中农业大学第五届程序设计大赛网络同步赛-D

    Problem D: GCD Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 179  Solved: 25[Submit][Status][Web B ...

随机推荐

  1. 转载:iOS 推送的服务端实现

    参考网址1: iOS消息推送机制的实现 http://www.cnblogs.com/qq78292959/archive/2012/07/16/2593651.html 参考网址2: iOS 推送的 ...

  2. BZOJ 3573 米特运输

    语文题... 原来除了hash还可以取对数啊orz #include<iostream> #include<cstdio> #include<cstring> #i ...

  3. I.MX6 android 获取framebuffer信息

    /******************************************************************************** * I.MX6 android 获取 ...

  4. rtp h264注意点(FU-A分包方式说明)

    前写过一篇文章,分析了h264使用rtp进行封包的格式介绍:RTP封装h264.但里面好像没有把拆分以及一些需要注意的情况说清楚,因此这里做补充,也作为自己的备忘(自己记性好像不太好). 关于时间戳, ...

  5. 一天一个Java基础——反射

    1.概念 反射主要是指程序可以访问,检测和修改它本身的状态或行为的一种能力 Java中的反射是一种强大的工具,它能够创建灵活的代码,这些代码可以运行时装配,无须在组件之间进行链接 反射允许在编写与执行 ...

  6. 【转】让 cocos2d-x 的 CCHttpRequest 支持https

    肖锐(Cooki)个人原创,欢迎转载,转载请注明地址,肖锐(Cooki)的技术博客 http://blog.csdn.net/xiao0026  由于游戏用到了网络头像, 今天发现换成facebook ...

  7. POJ 2136 Vertical Histogram

    题意:按样例那样模拟…… 解法:模拟…… 代码: #include<stdio.h> #include<iostream> #include<algorithm> ...

  8. [Everyday Mathematics]20150116

    设 $\al_n\geq 0$ 且 $\dps{\vlm{n}\al_n=0}$, 试求 $$\bex \vlm{n}\frac{1}{n}\sum_{k=1}^n \ln\sex{\frac{k}{ ...

  9. bzoj1150

    haha,贪心,边界条件折腾了我一会儿 #include<cstdio> #include<cctype> #include<queue> #include< ...

  10. springmvc基础知识

    springmvc框架,类似于struts,主要用于MVC的控制层 spring的简单配置(非注解):  spring-mvc.xml文件(springMVC框架的基本文件) web.xml文件 ja ...