Cod sursa(job #2411495)

Utilizator bluestorm57Vasile T bluestorm57 Data 20 aprilie 2019 19:51:50
Problema Branza Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <fstream>

using namespace std;

ifstream f("branza.in");
ofstream g("branza.out");

const int inf = (1 << 30);
const int Nmax = 100005;
int v[Nmax], best[Nmax];
int cant[Nmax], cost[Nmax];
long long int suma;
int n,s,t;

int main(){
    int i,j;
    f >> n >> s >> t;
    for(i = 1; i <= n ; i++){
        f >> cost[i] >> cant[i];
        best[i] = inf;
    }

    for(i = 1 ; i <= n ; i++){
        best[i] = min (best[i], cost[i] * cant[i]);

        for(j = i + 1 ; j <= n && j - i <= t ; j++)
            best[j] = min(best[j], cost[i] * cant[j] + cant[j] * s * (j - i));
    }

    for(i = 1; i <= n ; i++)
        suma += best[i];//, g << best[i] << " ";

    g << suma;
    return 0;
}