A: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

SAMPLE OUTPUT

题目链接:http://ifrog.cc/acm/problem/1014?contest=1001&no=0

*************************************

错误代码:(貌似错的还挺离谱,没办法,太弱了)

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<time.h>
#include<stack>
using namespace std;
#define N 120000
#define INF 0x3f3f3f3f int a[N]; int main()
{
int T,n,m,k,i; scanf("%d", &T); while(T--)
{
scanf("%d %d %d", &n,&m,&k); for(i=; i<n; i++)
scanf("%d", &a[i]); sort(a,a+n); int i=,sum=;
while(i<n)
{
if(m-a[i]>)
sum+=m-a[i];
i+=k;
}
printf("%d\n",sum);
} return ;
}

 比赛全部的题从链接里面找,有兴趣的可以自己做做看。下面是全部题解:

“玲珑杯”ACM比赛 Round #1 题解的更多相关文章

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

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

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

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

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

    A 题目链接:http://www.ifrog.cc/acm/problem/1111 分析:容易发现本题就是排序不等式, 将A数组与B数组分别排序之后, 答案即N∑i=1Ai×Bi 此题有坑,反正据 ...

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

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

  6. “玲珑杯”ACM比赛 Round #18

    “玲珑杯”ACM比赛 Round #18 Start Time:2017-07-15 12:00:00 End Time:2017-07-15 15:46:00 A -- 计算几何你瞎暴力 Time ...

  7. “玲珑杯”ACM比赛 Round #18--最后你还是AK了(搜索+思维)

    题目链接   DESCRIPTION INPUT OUTPUT SAMPLE INPUT 1 4 2 1 2 5 2 3 5 3 4 5 5 5 SAMPLE OUTPUT 35 HINT 对于样例, ...

  8. 玲珑杯”ACM比赛 Round #4 1054 - String cut 暴力。学到了扫描的另一种思想

    http://www.ifrog.cc/acm/problem/1054 问删除一个字符后的最小循环节是多少. 比赛的时候想不出,不知道怎么暴力. 赛后看了别人代码才晓得.唉,还以为自己字符串还不错, ...

  9. lonlifeOJ1152 “玲珑杯”ACM比赛 Round #19 概率DP

    E -- Expected value of the expression DESCRIPTION You are given an expression: A0O1A1O2A2⋯OnAnA0O1A1 ...

随机推荐

  1. BFS详解

    广度优先搜索详解          1. 也称宽度优先搜索,顾名思义,就是将一棵树一层一层往下搜.算法首先搜索和s距离为k的所有顶点,然后再去搜索和S距离为k+l的其他顶点.BFS是一种完备策略,即只 ...

  2. C#第六天

    字符串的处理练习: 课上练习1:接收用户输入的字符串,将其中的字符以与输入相反的顺序输出."abc"→"cba" 方法1: string str = " ...

  3. Python 学习笔记5

    Life is like a box of chocolate. 今天继续学习Python数据结构. http://www.pythondoc.com/pythontutorial3/datastru ...

  4. mysql5.7.16安装

    系统:centOS6.5 mysql: 5.7.16 wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16-linux-glib ...

  5. mac中Eclipse的快捷键

    查看某个类:command + shift +T 快速查看源代码中方法: command + o 选中某个类,command + t:查看此类的父类和子类 如果要导入一个类所在的包名,可以选中这个类, ...

  6. BaLaBaLa

    #include<cstdio>#include<cstring>#include<cmath>#include<queue>#include<a ...

  7. php给数组key:value中的key加引号

    public function Ext_json_decode($str, $mode=false){ if(preg_match('/\w:/', $str)){ $str = preg_repla ...

  8. www.iis.net

    http://www.iis.net 这是一个神奇的网站 关于IIS的所有管理,在这里都能找到 今天,一个同事问我,  iis8 php的设置,一个环境变量的东西不知道怎么去设置, 然后我搜了下,在 ...

  9. 关于PHP执行超时的问题

    PHP配置文件的参数max_execution_time表示脚本执行超时时间 max_execution_time=0表示不限制 max_execution_time=2表示执行两秒后终止,同时报错F ...

  10. MySQL函数大全【转载】

    转载自 http://www.jb51.net/article/40179.htm 一.数学函数ABS(x)   返回x的绝对值BIN(x)   返回x的二进制(OCT返回八进制,HEX返回十六进制) ...