Pagini recente » Borderou de evaluare (job #2591257) | Borderou de evaluare (job #2938312) | Borderou de evaluare (job #205327) | Borderou de evaluare (job #1128998) | Cod sursa (job #2412010)
#include <fstream>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
const int inf = (1 << 30);
const int Nmax = 100005;
typedef long long int ll;
ll v[Nmax], best[Nmax];
ll cant, cost[Nmax];
ll suma;
ll n,s,t;
ll last;
ll value;
int main(){
ll i,j;
f >> n >> s >> t;
last = 1;
for(i = 1; i <= n ; i++){
f >> cost[i] >> cant;
best[i] = inf;
for(j = last ; j <= i ; j++){
value = cost[j] * cant + (i - j) * cant * s;
if(value < best[i])
best[i] = value, last = j;
}
if(i - last == t - 1)
last++;
}
for(i = 1 ; i <= n ; i++)
suma += best[i];
g << suma;
return 0;
}