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 <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,m,k,t,i;
int a[];
ll ans,pos;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
for(i=;i<n;i++)
scanf("%d",&a[i]);
pos=;
for(i=;i<n;i++)
{
if(a[i]<m)
{
ans=m-a[i];
pos+=ans;
for(int j=i;j<i+k;j++)
{
a[j%n]+=ans;
}
}
}
printf("%lld\n",pos);
}
return ;
}

玲珑学院 1014 Absolute Defeat的更多相关文章

  1. 玲珑学院-ACM比赛1014 - Absolute Defeat

    1014 - Absolute Defeat Time Limit:2s Memory Limit:64MByte Submissions:257Solved:73 DESCRIPTION Eric ...

  2. 玲珑学院oj 1152 概率dp

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

  3. 玲珑学院1072 【DFS】

    蛤蛤,略蠢. priority_queue 自定义优先级 和排序是反的 struct node { int x,y; friend bool operator< (node a,node b) ...

  4. 玲珑学院OJ 1023 - Magic boy Bi Luo with his excited math problem 树状数组暴力

    分析:a^b+2(a&b)=a+b  so->a^(-b)+2(a&(-b))=a-b 然后树状数组分类讨论即可 链接:http://www.ifrog.cc/acm/probl ...

  5. 玲珑学院OJ 1028 - Bob and Alice are playing numbers 字典树,dp

    http://www.ifrog.cc/acm/problem/1028 题解处:http://www.ifrog.cc/acm/solution/4 #include <cstdio> ...

  6. 玲珑学院 1010 - Alarm

    1010 - Alarm Time Limit:1s Memory Limit:128MByte DESCRIPTION Given a number sequence [3,7,22,45,116, ...

  7. 玲珑学院 1050 - array

    1050 - array Time Limit:3s Memory Limit:64MByte Submissions:494Solved:155 DESCRIPTION 2 array is an ...

  8. 玲珑学院 1052 - See car

    1052 - See car Time Limit:2s Memory Limit:64MByte Submissions:594Solved:227 DESCRIPTION You are the ...

  9. “玲珑杯”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 ...

随机推荐

  1. GoldenGate V11.1数据复制限制

    以下对goldengate数据复制的限制情况进行说明. 不支持文件等非结构化数据复制 GoldenGate依赖对于数据库日志的解析获取数据变化,因此只能支持数据库中的数据变化复制,无法支持文件等非结构 ...

  2. ES6学习笔记(十六)async函数

    1.含义 ES2017 标准引入了 async 函数,使得异步操作变得更加方便. async 函数是什么?一句话,它就是 Generator 函数的语法糖,号称异步的终极解决方案. 前文有一个 Gen ...

  3. 题解 P1198 【[JSOI2008]最大数】

    说起来这还是蒟蒻AC的第一道省选线段树呢. 这道题和其他线段树最大的不同就是在于本题数组一直在增大. 寻常的线段树蒟蒻习惯用如下的结构体储存,然而对于此题就不行了: struct node{ int ...

  4. C# 字符串 分割 反转 Base64

    "; //字符串 ToBase64 byte[] bytes = Encoding.Default.GetBytes(pwd); pwd = Convert.ToBase64String(b ...

  5. [Poi] Customize Babel to Build a React App with Poi

    Developing React with Poi is as easy as adding the babel-preset-react-appto a .babelrc and installin ...

  6. centos7;windows下安装和使用spice

    感谢朋友支持本博客,欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免,欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  7. oracle_序列、索引、同义词

     ①序列 1.序列: 可供多个用户用来产生唯一数值的数据库对象     自己主动提供唯一的数值     共享对象     主要用于提供主键值     将序列值装入内存能够提高訪问效率 2.CREA ...

  8. 彻底解决lazarus安装组件后烦人的编译时单元找不到的问题!

    以安装indy为例 1/下载组件包, http://www.indyproject.org/Sockets/fpc/indy-10.2.0.3.zip 2/爆开放于C:\lazarus\compone ...

  9. SQL大小写金额转换

    --功能: 用于将小写的数值翻译成大写的字符串(支持到分,即小数点后两位) --入口参数:@decNum------数字型变量 --返回:字符串 --举例:select dbo.fn_ChnMoney ...

  10. BZOJ 3631 链剖+差分

    思路: 1.树链剖分+用带标记的线段树维护操作(复杂度O(nlog2n)) 2.树链剖分LCA(TarjanLCA等各种LCA)+差分 复杂度(O(n)->O(nlogn)之间) 下面就说说怎么 ...