Pagini recente » Cod sursa (job #645233) | Cod sursa (job #2959067) | Cod sursa (job #2888024) | Cod sursa (job #2300274) | Cod sursa (job #2411495)
#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;
}