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. Repeated Substring Pattern --重复字符串

    Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...

  2. 版本12.2.0.1.0数据库,复制种子数据库快速创建租户数据库PDB

    实验测试:快速创建一个数据库PDB2: 实验环境:12.2.0.1.0版本数据库,dbca图形化安装,现有环境,CDB容器数据库ORCL,PDB可插拔数据库ABC   ---查询CDB名称,状态 SQ ...

  3. Lua5.3 注册表 _G _ENV

    Lua5.3 注册表 _G _ENV 来源:http://blog.csdn.net/murisly/article/details/46518551 注册表的描述,借用PIL中的一段话: regis ...

  4. Leetcode题解(十)

    29.Divide Two Integers 题目 题目要求不用乘除和取模运算,实现两个整数相除: 我的第一想法就是把除法变成减法来做,这也是最初除法的定义,其实现代码如下: class Soluti ...

  5. C++ 随机生成一个(0,1)之间的小数

    double p; ]; memset(s,,sizeof(s)); s[]='; s[]='.'; ;i<;i++) { s[i]=rand()%+'; } p=atof(s); cout & ...

  6. 【20171104中】chrome自动刷新网页

    target:刷访问量 tools:chrome / url start: s1:百度知道,https://zhidao.baidu.com/question/750134067096113532.h ...

  7. Max Sum Plus Plus

    A - Max Sum Plus Plus Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  8. Android 开发笔记___滚动视图__scroll view

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  9. 对象作为 handleEvent

    elem.addEventListener("click", obj, false);    //用对象作为处理函数   var obj = {     handleEvent: ...

  10. Task及Mvc的异步控制器 使用探索

    微软的Task已经出来很久了,一直没有去研究,以为就是和Thread差不多的东西.直到最近看到了Task的使用介绍,发现比Thread的语法要精炼多了,于是便在项目中用上了. 结果就出问题了,数据库连 ...