Cod sursa(job #1848416)

Utilizator mariusn01Marius Nicoli mariusn01 Data 15 ianuarie 2017 23:49:06
Problema Progresii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.85 kb
#include <fstream>
#include <iostream>
#define DIM 100010
using namespace std;
ifstream fin ("progresii.in");
ofstream fout("progresii.out");

long long N, M, K, L, x[DIM], t;
long long Min[DIM], S[DIM], sol[DIM];

int main () {
    ifstream fin ("progresii.in");
    ofstream fout("progresii.out");
    fin>>N>>M>>K>>L;
    for (int i=1;i<=N;i++) {
        fin>>x[i];
        x[i] = L-x[i];
        S[i] = S[i-1] + x[i]/M;
        //cout<<Min[i]<<" ";
    }
    K-=N;
    if (S[N] > K) {
        fout<<-1;
        return 0;
    }
    for (int i=1;i<=N;i++) {

        long long maxAcceptedSeconds = K - (S[N]-S[i]) + 1;

        sol[i] = x[i]/maxAcceptedSeconds + 1;
        if (x[i] <= K - (S[N]-S[i]))
            sol[i] = 1;

        K-=x[i]/sol[i];
    }
    for (int i=1;i<=N;i++)
        fout<<sol[i]<<"\n";
    return 0;
}