1014 - Absolute Defeat

Time Limit:2s Memory Limit:64MByte

Submissions:257Solved:73

DESCRIPTION
Eric has an array of integers
a1,a2,...,ana1,a2,...,an.
Every time, he can choose a contiguous subsequence of length
kk
and increase every integer in the contiguous subsequence by
11.He
wants the minimum value of the array is at least
mm.
Help him find the minimum number of operations needed.
INPUT
There are multiple test cases. The first line of input contains an integer
TT,
indicating the number of test cases. For each test case:The first line contains three integers
nn,
mm
and kk
(1≤n≤105,1≤k≤n,1≤m≤104)(1≤n≤105,1≤k≤n,1≤m≤104).The
second line contains nn
integers a1,a2,...,ana1,a2,...,an
(1≤ai≤104)(1≤ai≤104).
OUTPUT
For each test case, output an integer denoting the minimum number of operations needed.
SAMPLE INPUT
32 2 21 15 1 41 2 3 4 54 10 31 2 3 4
SAMPLE OUTPUT

1015

源代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<ctime>
using namespace std; typedef long long ll;
int ans[200005]; int main()
{
int t;
int n,m,k;
int temp;
ll sum;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
sum = 0;
memset(ans,0x3f3f3f3f,sizeof(ans));
for(int i = 0; i < n; i++)
scanf("%d",&ans[i]);
for(int i = 0; i < n; i++)
{
if(ans[i]<m)
{
temp=m-ans[i];
sum+=temp;
for(int j = i; j < i+k;j++)
ans[j]+=temp;
}
}
printf("%lld\n",sum);
}
return 0;
}

玲珑学院-ACM比赛1014 - Absolute Defeat的更多相关文章

  1. 玲珑学院 1014 Absolute Defeat

    SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15 前缀和,每个元素都判断一下. #include ...

  2. “玲珑杯”ACM比赛 Round #1

    Start Time:2016-08-20 13:00:00 End Time:2016-08-20 18:00:00 Refresh Time:2017-11-12 19:51:52 Public ...

  3. “玲珑杯”ACM比赛 Round #1 题解

    A:DESCRIPTION Eric has an array of integers a1,a2,...,ana1,a2,...,an. Every time, he can choose a co ...

  4. “玲珑杯”ACM比赛 Round #12题解&源码

    我能说我比较傻么!就只能做一道签到题,没办法,我就先写下A题的题解&源码吧,日后补上剩余题的题解&源码吧!                                     A ...

  5. ACM比赛经验

    这篇博客是转别人的,觉得很好,希望能在以后的现场赛中用上:ACM比赛经验 推荐此篇文章打印,与模板放在一起. 1. 比赛中评测会有些慢,偶尔还会碰到隔10分钟以上才返回结果的情况,这段时间不能等结果, ...

  6. “玲珑杯”ACM比赛 Round #19题解&源码【A,规律,B,二分,C,牛顿迭代法,D,平衡树,E,概率dp】

    A -- simple math problem Time Limit:2s Memory Limit:128MByte Submissions:1599Solved:270 SAMPLE INPUT ...

  7. ACM比赛_注意

    ACM比赛_注意: 比赛前: 1.前一天早一点睡觉 2.避免参加激烈的活动,以免比赛时精力不足; 3.少喝水,并提前上厕所; 4.把账号,密码都准备好,放在txt中 5.提前创建多个程序(etc.10 ...

  8. 玲珑学院oj 1152 概率dp

    1152 - Expected value of the expression Time Limit:2s Memory Limit:128MByte Submissions:128Solved:63 ...

  9. “玲珑杯”ACM比赛 Round #19 B -- Buildings (RMQ + 二分)

    “玲珑杯”ACM比赛 Round #19 Start Time:2017-07-29 14:00:00 End Time:2017-07-29 16:30:00 Refresh Time:2017-0 ...

随机推荐

  1. 关于docker使用的几个小问题(二)

    很久没写博客了,集中写几个比较有意思的小问题. 一.CentOS容器没有service命令 这是因为我们从docker官方镜像仓库中pull的最新CentOS镜像都是centos7.4 Redhat- ...

  2. .NET Core 使用RSA算法 加密/解密/签名/验证签名

    前言 前不久移植了支付宝官方的SDK,以适用ASP.NET Core使用支付宝支付,但是最近有好几位用户反应在Linux下使用会出错,调试发现是RSA加密的错误,下面具体讲一讲. RSA在.NET C ...

  3. iOS之 NSTimer(二)

    1. Stopping a Timer  关闭定时器 if you create a non-repeating timer, there is no need to take any further ...

  4. Milking Time

    Description Bessie is such a hard-working cow. In fact, she is so focused on maximizing her producti ...

  5. Node.js EventEmitter

    Node.js EventEmitter Node.js 所有的异步 I/O 操作在完成时都会发送一个事件到事件队列. Node.js里面的许多对象都会分发事件:一个net.Server对象会在每次有 ...

  6. html5客户端本地存储之sessionStorage及storage事件

    首先您可以看一下<JavaScript本地存储实践(html5的localStorage和ie的userData)>sessionStorage和上文中提到的localStorage非常相 ...

  7. python3.0 模拟用户登录,三次错误锁定

    # -*- coding:utf-8 -*- #需求模拟用户登录,超过三次错误锁定不允许登陆     count = 0   #realname passwd Real_Username = &quo ...

  8. mac链接linux终端,shell脚本发布代码

    项目的业务需求:从mac端直接连上linux服务终端,并发布相关的代码 一.使用ssh链接上linux服务端 1.cd ~/.ssh 2.vi config,按照下面的内容配置config文件,然后: ...

  9. python实现查有道词典

    因为要考英语四级,所以我今天一大早就起来被英语单词,但是作为英语渣渣的我,只能是在网页上挨个查单词的意思.查的多了,心生厌倦,便想着如何才能在终端下查单词,那样速度不就很快了? NOW,我仔细观察每次 ...

  10. 新增加的HTTP状态码 -- 103

    IETF公布了新的HTTP状态码-103, 总结一下就是提前预加载(css.js)文档,提升用户的访问速度. Summary: a new status code that lets the serv ...