【1014 - Absolute Defeat】
发布日期:2021-11-04 12:59:38
浏览次数:4
分类:技术文章
本文共 1420 字,大约阅读时间需要 4 分钟。
1014 - Absolute Defeat
DESCRIPTION
Eric has an array of integers a 1 , a 2 , . . . , a n a1,a2,…,an. Every time, he can choose a contiguous subsequence of length k k and increase every integer in the contiguous subsequence by 1 1.He wants the minimum value of the array is at least
m m. Help him find the minimum number of operations needed. INPUT There are multiple test cases. The first line of input contains an integer T T, indicating the number of test cases. For each test case:The first line contains three integers
n n, m m and k k ( 1 ≤ n ≤ 10 5 , 1 ≤ k ≤ n , 1 ≤ m ≤ 10 4 ) (1≤n≤105,1≤k≤n,1≤m≤104).The second line contains
n n integers a 1 , a 2 , . . . , a n a1,a2,…,an ( 1 ≤ a i ≤ 10 4 ) (1≤ai≤104). OUTPUT For each test case, output an integer denoting the minimum number of operations needed. 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 SOLUTION “玲珑杯”ACM比赛 Round #1#includeint pa[100011];int main(){ int n,m,k,T,i,j,ans,kl; scanf("%d",&T); while(T--) { scanf("%d%d%d",&n,&m,&k); for(i = 1; i <= n; i++) scanf("%d",&pa[i]); ans = 0; for(i = 1; i <= n; i++) { if(pa[i] < m) { kl = m - pa[i]; for(j = i ; j < i + k && j <= n; j++) pa[j] += kl; ans += kl; } } printf("%d\n",ans); } return 0;}
转载地址:https://blog.csdn.net/WYK1823376647/article/details/52553994 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
初次前来,多多关照!
[***.217.46.12]2024年03月15日 21时43分12秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
android 动态毛玻璃,Android毛玻璃背景效果简单实现代码
2019-04-21
android 按钮提示,的Android按钮工具提示
2019-04-21
win7自定义html为桌面,Win7系统自定义桌面主题的方法
2019-04-21
linux存储pdf伟岸_python的reportlab库介绍、制作pdf和作图
2019-04-21
安徽信息技术初中会考上机考试模拟_2020年中小学寒假、考试时间定下了!
2019-04-21
稳定币usda是哪个发行的_武夷山币装帧款曝光,共4款设计,你喜欢哪款?
2021-06-24
苹果笔记本的end键_笔记本用户的大烦恼:触控板,想好好用你不容易
2019-04-21
趣玩机器人什么时候成立的_【直播回顾】当我们谈机器人集成调试的时候在谈什么...
2019-04-21
vue 地理位置定位_HTML5地理位置
2019-04-21
pac代理模式什么意思_托管仓库租赁电商仓储运营模式托管什么意思
2019-04-21
validated 验证数组_在 Laravel 中处理请求验证的智能方法
2019-04-21
java 拼接路径优雅方式_Java安全编码实践总结
2019-04-21
realme x2 深度测试打不开_搭载65W超级闪充,realme真我X7手机充电评测
2019-04-21