Cod sursa(job #3329367)

Utilizator Radu_BicliBiclineru Radu Radu_Bicli Data 12 decembrie 2025 23:54:22
Problema Branza Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.96 kb
#include <bits/stdc++.h>

using namespace std;

#define USE_STD_IO 0
//#define if(USE_STD_IO) cout
#if USE_STD_IO
    #define fin cin
    #define fout cout
#else
    ifstream fin("branza.in");
    ofstream fout("branza.out");
#endif // USE_STD_IO

struct Saptamana {
    long long cost, cerere;
};
long long n, s, t, i, j, costCur, rasp;
Saptamana v[100002];

int main() {
    if(USE_STD_IO) ios_base::sync_with_stdio(false);
    fin.tie(nullptr);
    fout.tie(nullptr);

    fin >> n >> s >> t;
    for(i = 1; i <= n; i++) {
        fin >> v[i].cost >> v[i].cerere;
    }

    for(i = n; i >= 1; i--) {
        costCur = v[i].cost;
        for(j = 1; j <= t && i + j <= n; j++) {
            costCur += s;
            if(v[i + j].cost > costCur) {
                v[i + j].cost = costCur;
            }
            else break;
        }
    }

    for(i = 1; i <= n; i++) rasp += v[i].cost * v[i].cerere;
    fout << rasp;

    return 0;
}