Pagini recente » Cod sursa (job #3144515) | Cod sursa (job #602577) | Cod sursa (job #1688592) | Cod sursa (job #2947283) | Cod sursa (job #2656412)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("progresii.in");
ofstream fout("progresii.out");
const int nmax = 100005;
int n;
long long m, k, l, v[nmax], cost;
int main(){
fin >> n >> m >> k >> l;
for (int i = 1; i <= n; ++i){
fin >> v[i];
cost = 1LL * cost + 1 + 1LL * (l - v[i]) / m;
if (cost > k){
fout << -1;
return 0;
}
}
for (int i = 1; i <= n; ++i){
cost = 1LL * cost - (1 + 1LL * (l - v[i]) / m);
long long b = k - cost - 1;
long long a = l - v[i];
long long x = m;
if (b == 0){
x = a + 1;
}
else{
x = a / b;
if (1LL * cost + 1 + 1LL * (l - v[i]) / x > k){
x = x + 1;
}
else if (x - 1 > 0 && 1LL * cost + 1 + 1LL * (l - v[i]) / (x - 1) <= k){
x = x - 1;
}
}
cost = 1LL * cost + 1 + 1LL * (l - v[i]) / x;
fout << x << "\n";
}
fin.close();
fout.close();
return 0;
}