(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 ...
随机推荐
- Save output to a text file from Mac terminal
Simply with output redirection: system_profiler > file.txt Basically, this will take the output ...
- JAVA中获取项目文件路径
在java中获得文件的路径在我们做上传文件操作时是不可避免的. web 上运行 1:this.getClass().getClassLoader().getResource("/" ...
- hdu4576 概率dp n^2的矩阵
这个题目看网上好多题解都是直接O(n*m)卡过.我是这么做的. 对于m次操作,统计每个w的次数.然后对每个w做矩阵乘法. 这样直接做矩阵乘法是会TLE的. 又由于这里的矩阵很特殊,一次乘法可以降维成O ...
- Java [Leetcode 168]Excel Sheet Column Title
题目描述: Given a positive integer, return its corresponding column title as appear in an Excel sheet. F ...
- Swift入门篇-swift简介
潜水博客园很多年,闲来无事,聊一下自己的经历,语文不好(如有什么错别字,请您在下评论)望您谅解,没有上过什么学的 在前期 ios入门篇 -hello Word(1) 文章中介绍我这半年准备写一些ios ...
- 分析一下FastDFS_java_client中TestClient.java这个文件以及跟它关联的这条线
本来先打算上个图来说明一下这条线的,可是我的画图工具还没有安装好,我先把跟TestClient.java相关的几个文件代码贴上来,但是由于代码行数还是不少的,所以请大家阅读文章的时候先不要展开代码,等 ...
- erl0004 - ets 安全遍历
safe_fixtable(Tab, true|false) -> true Types: Tab = tid() | atom() 锁定set,bag和 ...
- Remove Duplicates from Sorted List I & II
Title: Given a sorted linked list, delete all duplicates such that each element appear only once. Fo ...
- BUFFER CACHE之主要的等待事件
原因:资源紧张,等待其释放. 原因的原因:1. lgwr和DBWn进程写太慢:2. Buffer和latch不可用 原因的原因的原因:全表扫描.library cache latches数太多等. 视 ...
- K2 blackpearl 流程开发(二)
转:http://blog.csdn.net/gxiangzi/article/details/8444590 本来想一篇文章把流程开发介绍完的,后来发现实在是太多了,只好分成两部分了.上一篇很简单的 ...