【CF edu 30 A. Chores】
time limit per test 2 seconds
memory limit per test 256 megabytes
input standard input
output standard output
Luba has to do n chores today. i-th chore takes ai units of time to complete. It is guaranteed that for every the conditionai ≥ ai - 1 is met, so the sequence is sorted.
Also Luba can work really hard on some chores. She can choose not more than k any chores and do each of them in x units of time instead of ai ().
Luba is very responsible, so she has to do all n chores, and now she wants to know the minimum time she needs to do everything. Luba cannot do two chores simultaneously.
Input
The first line contains three integers n, k, x (1 ≤ k ≤ n ≤ 100, 1 ≤ x ≤ 99) — the number of chores Luba has to do, the number of chores she can do in x units of time, and the number x itself.
The second line contains n integer numbers ai (2 ≤ ai ≤ 100) — the time Luba has to spend to do i-th chore.
It is guaranteed that , and for each ai ≥ ai - 1.
Output
Print one number — minimum time Luba needs to do all n chores.
Examples
input
4 2 2
3 6 7 10
output
13
input
5 2 1
100 100 100 100 100
output
302
Note
In the first example the best option would be to do the third and the fourth chore, spending x = 2 time on each instead of a3 and a4, respectively. Then the answer is 3 + 6 + 2 + 2 = 13.
In the second example Luba can choose any two chores to spend x time on them instead of ai. So the answer is 100·3 + 2·1 = 302.
题解:
①Implentation直接做就是了
#include<stdio.h>
#define go(i,a,b) for(int i=a;i<=b;i++)
int n,k,x,a[],sum;
int main()
{
scanf("%d%d%d",&n,&k,&x);
go(i,,n)scanf("%d",a+i);
go(i,,n-k)sum+=a[i];
printf("%d\n",sum+k*x);return ;
}//Paul_Guderian
.
【CF edu 30 A. Chores】的更多相关文章
- 【CF edu 30 D. Merge Sort】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【CF edu 30 C. Strange Game On Matrix】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standa ...
- 【Cf edu 30 B. Balanced Substring】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF contest/792/problem/E】
E. Colored Balls time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- 【CF Round 434 A. k-rounding】
Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...
- 【CF Round 429 B. Godsend】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【CF Manthan, Codefest 17 B】Marvolo Gaunt's Ring
[链接]h在这里写链接 [题意] 给你n个数字; 让你在其中找出三个数字i,j,k(i<=j<=k); 使得p*a[i]+q*a[j]+r*a[k]最大; [题解] /* 有一个要 ...
- 【CF Manthan, Codefest 17 A】Tom Riddle's Diary
[链接]h在这里写链接 [题意] 在这里写题意 [题解] /* Be careful. 二重循环枚举 */ [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/st ...
- 【CF 676B Pyramid of Glasses】模拟,递归
题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求 ...
随机推荐
- ThinkPHP框架目录的介绍
library目录 Think目录 mvc
- ruby Time类与Date类
Time类用于表示时间.时间除了表示年月日时分秒的信息外,还包含了表示地域时差的时区(time zone)信息.例如我们可以计算中国当前时间是国际协调时间的几点 Date类只用于表示年月日.因此,相对 ...
- Linux Shell 与Linux常用命令
Linux的人际交互分为图形界面方式和命令行方式. Linux本身只是一个操作系统内核,而由X Window图形用户接口为Linux提供图形用户界面功能.可以把X Window理解为一个运行在Linu ...
- Hibernate-ORM:04.Hibernate中的get()和load()
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客会讲如何用get()或load()查询单个对象和对缓存的简单操作,以及他俩的区别和相同(前面有的那些配 ...
- 类 java.util.Collections 提供了对Set、List、Map进行排序、填充、查找元素的辅助方法。
类 java.util.Collections 提供了对Set.List.Map进行排序.填充.查找元素的辅助方法. 1. void sort(List) //对List容器内的元素排序,排序的规 ...
- Lambda方式左连接有Linq方式左连接
网上查到的直接使用Join+DefaultIfEmpty的方式是错误的,实际生成SQL是两表先内联接,然后再LEFT JOIN.经过查证,参考资料,最终得到如下两种方式的左连接写法: public v ...
- [转]Visual Studio 项目类型 GUID 清单
转自:https://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs Complete li ...
- dom知识总结
一.dom节点的关系及遍历 element.firstChild; 如果节点为已知节点的第一个子节点就可以使用这个方法.此方法可以递归进行使用 element.firstChild.firstChil ...
- js解决img标签加载失败显示默认图片
问题: 为所有显示楼盘的页面添加一个加载失败的默认图片. 基本思路: img标签中有个onerror属性,专门用来处理加载失败的事件.所以可以用jquery添加onerror属性,在onerror中加 ...
- 「暑期训练」「Brute Force」 Restoring Painting (CFR353D2B)
题意 给定一定条件,问符合的矩阵有几种. 分析 见了鬼了,这破题谁加的brute force的标签,素质极差.因为范围是1e5,那你平方(枚举算法)的复杂度必然爆. 然后你就会思考其中奥妙无穷的数学规 ...