2021-07-17 AcWing 3769. 移动石子
输入样例:
3 4 5 1 0 3 2 2 2 100 1 1 8 0
输出样例:
3 101 0
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int T;
int n,step,x;
cin >> T;
while (T -- )
{
int res = 0 ;
cin >> n >> step;
for (int i = 0; i < n; i ++ )
{
cin >> x;
if(!i){
res += x;
}else{
int m = min(x,step/i);
res += m;
step -= m*i;
}
}
cout << res << endl;
}
return 0;
}
本文来自博客园,作者:泥烟,CSDN同名, 转载请注明原文链接:https://www.cnblogs.com/Knight02/p/15799168.html