Time Limit:2s Memory Limit:64MByte
Submissions:257Solved:73
1015
【解题方法】思维。从左往右枚举每个元素, 如果不够的话, 直接把这个元素起始的长度为m的序列都改一下就好了.
【AC 代码】
//
//Created by just_sort 2016/9/25 21:03
//Copyright (c) 2016 just_sort.All Rights Reserved
//
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int a[1000010];
int main()
{
int T,n,k,m;
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&n,&m,&k);
for(int i=1; i<=n; i++) scanf("%d",&a[i]);
int ans = 0;
int temp;
for(int i=1; i<=n; i++){
if(a[i]<m){
temp = m - a[i];
ans += temp;
for(int j=i; j<i+k; j++){
a[j] += temp;
}
}
}
printf("%d\n",ans);
}
return 0;
}
125



被折叠的 条评论
为什么被折叠?



