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. yii2布局选择与属性标签设置

    Yii选择布局的方法: 1. 通过控制器成员变量设置: public $layout = false;//不使用布局 public $layout = 'main';//设置使用的布局文件(@app/ ...

  2. 微信小程序之给项目设置id后提示不在合法域名列别中

    hotapp 有免费的https proxy ,可以免费代理请求任何http或者https服务,只要设置好合法域名为https://wxapi.hotapp.cn, 就可以请求网址如请求小程序联盟的例 ...

  3. DUBBO初探-搭建DUBBO开发环境

    我所理解的DUBBO 相对于传统web开发框架,dubbo更加适合于并行系统开发,分布式,模块化.将server和client都注册到zookeeper注册中心上,然后由最外层客户端发起请求到相应cl ...

  4. 走近 Python (类比 JS)

    Python 是一门运用很广泛的语言,自动化脚本.爬虫,甚至在深度学习领域也都有 Python 的身影.作为一名前端开发者,也了解 ES6 中的很多特性借鉴自 Python (比如默认参数.解构赋值. ...

  5. QT信号和槽

    QT信号和槽 ============ 信号和槽是一种高级接口,应用于对象之间的通信,它是 QT 的核心特性.要正确的处理信号和槽,必须借助一个称为 moc(Meta Object Compiler) ...

  6. Leetcode题解(25)

    77. Combinations 题目 分析:求给定数字n,k的组合数,方法是采用深度搜索算法,代码如下(copy网上代码) class Solution { public: void dfs77(v ...

  7. 数位DP按位枚举模板

    借鉴:http://www.cnblogs.com/xz816111/p/4809913.html // pos = 当前处理的位置(一般从高位到低位) // pre = 上一个位的数字(更高的那一位 ...

  8. 详细解读-this-关键字在全局、函数、对象、jQuery等中的基础用法!

    一.前言 1. Javascript是一门基于对象的动态语言,也就是说,所有东西都是对象,一个很典型的例子就是函数也被视为普通的对象.Javascript可以通过一定的设计模式来实现面向对象的编程,其 ...

  9. 安装Windows Azure Powershell

    本文将介绍如何安装Windows Azure Powershell 1.打开Azure官方链接:https://www.azure.cn/downloads/ 2.按照向导进行安装 3.打开系统自带的 ...

  10. HTML学习笔记 cs2D3D展示基础 第十四节 (原创) 参考使用表

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...