Pagini recente » Cod sursa (job #2440385) | Cod sursa (job #773552) | Rating Axenie Raisa (raisacmt) | Cod sursa (job #218271) | Cod sursa (job #2723977)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("branza.in");
ofstream g ("branza.out");
int main()
{
int n, s, t;
f >> n >> s >> t;
int m[n][2];
for (int i =0; i< n; i++){
f >> m[i][0] >> m[i][1];
}
int total=0;
for (int i = 0; i < n;i ++){
if (m[i][1]){
total += m[i][0] * m[i][1];
m[i][1] = 0;
}
for (int j = 0; j < t; j++){
if (i+j+1 < n){
if (m[i][0]+(j+1)*s < m[i+j+1][0]){
m[i+j+1][0] = m[i][0]+(j+1)*s;
}
}
}
}
g << total;
return 0;
}