
玲珑学院-ACM比赛1014 - Absolute Defeat
发布日期:2021-05-09 04:21:08
浏览次数:17
分类:原创文章
本文共 1744 字,大约阅读时间需要 5 分钟。
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;}
发表评论
最新留言
很好
[***.229.124.182]2025年05月23日 01时49分53秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Mac下安装PIL库
2025-04-11
mac下安装配置nginx
2025-04-11
Mac下忘记MySQL密码可以这样做!
2025-04-11
Mac下配置多个SSH-Key (gitLab)
2025-04-11
mac关闭占用某个端口的进程
2025-04-11
mac删除appstore账号和更新失败的问题
2025-04-11
mac地址随机变化的解决方法(安卓手机通用)不用ROOT
2025-04-11
Mac备忘录内容突然全部消失恢复
2025-04-11
mac如何查看连过的wifi密码
2025-04-11
mac安全权限解决
2025-04-11
Mac安装FastDFS
2025-04-11
Mac安装Maven
2025-04-11
Mac安装MySQL详细教程
2025-04-11
Mac实现远程服务器登录管理
2025-04-11
mac常用命令
2025-04-11
Mac打包dmg文件(更换背景图)
2025-04-11
Mac搭建appium环境
2025-04-11
Mac搭建Cocos2d-x 3.x android打包环境
2025-04-11
mac更新后 homestead 无法使用
2025-04-11
mac环境安装docker
2025-04-11