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.

【分析】:傻逼贪心。控制前n-k个数组求本位和,其他换成k求和。

【代码】:

#include <bits/stdc++.h>

using namespace std;

int main()
{
int n,k,x;
int a[];
while(~scanf("%d%d%d",&n,&k,&x))
{
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
int sum=;
for(int i=;i<n-k;i++)
{
sum+=a[i];
}
for(int i=n-k+;i<=n;i++)
{
sum+=x;
}
printf("%d\n",sum);
}
return ;
}
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
x=;int f=;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-;ch=getchar();}
while(isdigit(ch))x=x*+ch-'',ch=getchar();
x*=f;
}
inline void readLong(ll &x) {
x=;int f=;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-;ch=getchar();}
while(isdigit(ch))x=x*+ch-'',ch=getchar();
x*=f;
}
/*================Header Template==============*/
int n,a,ans=,k,x;
int main() {
readInt(n);
readInt(k);
readInt(x);
for(int i=;i<=n;i++) {
readInt(a);
if(i<=n-k)
ans+=a;
else
ans+=x;
}
printf("%d\n",ans);
return ;
}

朋友的

Educational Codeforces Round 30 A[水题/数组排序]的更多相关文章

  1. Educational Codeforces Round 30

    Educational Codeforces Round 30  A. Chores 把最大的换掉 view code #pragma GCC optimize("O3") #pr ...

  2. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  3. Educational Codeforces Round 30 B【前缀和+思维/经典原题】

    B. Balanced Substring time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Educational Codeforces Round 24 A 水 B stl C 暴力 D stl模拟 E 二分

    A. Diplomas and Certificates time limit per test 1 second memory limit per test 256 megabytes input ...

  5. Educational Codeforces Round 12 B C题、

    B. Shopping 题意:n个顾客,每个顾客要买m个物品,商场总共有k个物品,看hint就只知道pos(x)怎么算了,对于每一个Aij在k个物品中找到Aij的位置.然后加上这个位置对于的数值,然后 ...

  6. Educational Codeforces Round 10 A B题、

    A. Gabriel and Caterpillar 题意: 就是说  一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方.毛毛虫从10点爬到22点.每小时爬的距离是a, 晚上22点到第二天早上10点 ...

  7. Educational Codeforces Round 30 D. Merge Sort

    题意:给你n和k,n代表有多少个数,k代表几次操作,求一个1到n的序列,要k次mergesort操作才能还原 Examples Input 3 3 Output 2 1 3 Input 4 1 Out ...

  8. Educational Codeforces Round 5

    616A - Comparing Two Long Integers    20171121 直接暴力莽就好了...没什么好说的 #include<stdlib.h> #include&l ...

  9. Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题

    Educational Codeforces Round 71 (Rated for Div. 2)-E. XOR Guessing-交互题 [Problem Description] ​ 总共两次询 ...

随机推荐

  1. P2161 [SHOI2009]会场预约

    题目描述 PP大厦有一间空的礼堂,可以为企业或者单位提供会议场地.这些会议中的大多数都需要连续几天的时间(个别的可能只需要一天),不过场地只有一个,所以不同的会议的时间申请不能够冲突.也就是说,前一个 ...

  2. MySQL in查询优化

    https://blog.csdn.net/gua___gua/article/details/47401621 MySQL in查询优化<一> 原创 2015年08月10日 17:57: ...

  3. POJ3349 Snowflake Snow Snowflakes (hash

    Snowflake Snow Snowflakes Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 48624   Accep ...

  4. bzoj 4836 [Lydsy1704月赛]二元运算 分治FFT+生成函数

    [Lydsy1704月赛]二元运算 Time Limit: 8 Sec  Memory Limit: 128 MBSubmit: 577  Solved: 201[Submit][Status][Di ...

  5. i=i+1与i+=1的区别及效率(Java)

    原博客地址 在做个java优化的PPT时,看到了i=i+1与i+=1的区别,在这之前还真没想到那么细. 1.x=x+1,x+=1及x++的效率哪个最高?为什么? x=x+1最低,因为它的执行如下. ( ...

  6. c++对拍实现

    直接上代码吧. #include<bits/stdc++.h> using namespace std; int main(){ while(1){ system("./cute ...

  7. 【洛谷 P3629】 [APIO2010]巡逻 (树的直径)

    题目链接 容易发现,当加一条边时,树上会形成一个环,这个环上的每个点都是只要走一次的,也就是说我们的答案减少了这个环上点的个数,要使答案最小,即要使环上的点最多,求出直径\(L\),则答案为\(2(n ...

  8. POJ 1062 昂贵的聘礼 (最短路 迪杰斯特拉 )

    题目链接 Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家拿不出这么多金币,便请 ...

  9. bzoj 1293 贪心

    首先我们可以将这道题看成一个数轴,数轴其中的某些点存在一些颜色,我们要选取最短的一段,使这段存 在所有颜色,那么我们使用指针i,j表示在j-i位置中包含的颜色,那么初值是0,0,我们先i++,同时添加 ...

  10. mybatis注解动态sql

    @Insert("INSERT INTO user (name, age, gender, experience) VALUES (<a href="http://www.o ...