Cod sursa(job #398302)

Utilizator AstronothingIulia Comsa Astronothing Data 18 februarie 2010 13:50:13
Problema Branza Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
    ifstream f("branza.in");
    ofstream f2("branza.out");
    int n,t,s;
    long long cost[100001];
    long long cant[100001];
    f>>n>>s>>t;
    for(int i=0; i<n; ++i)
        f>>cost[i]>>cant[i];

    long long suma = 0;
    suma += cant[0]*cost[0];
    for(int i=1; i<n; ++i)
    {
        long long min = cant[i]*cost[i];
        int j = i-t;
        j = j<0 ? 0 : j;
        for(j = j; j<i; ++j)
            min = min>(cant[i]*cost[j]+s*cant[i]*(i-j)) ? (cant[i]*cost[j]+s*cant[i]*(i-j)) : min;
        suma += min;
    }

    f2<<suma;

    return 0;
}