Cod sursa(job #67438)

Utilizator fluffyDan-Leonard Crestez fluffy Data 24 iunie 2007 20:20:01
Problema Branza Scor Ascuns
Compilator cpp Status done
Runda Marime 0.74 kb
#include <fstream>
#include <vector>

using namespace std;

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

int n, s, t;
vector<int> c;
vector<int> p;

void read()
{
    in >> n >> s >> t;
    c.reserve(n);
    p.reserve(n);
    for (int i = 0; i < n; ++i) {
        int a, b;
        in >> a >> b;
        c.push_back(a);
        p.push_back(b);
    }
}

long long solve()
{
    long long result = 0;
    int price = -1;
    for (int i = 0; i < n; ++i) {
        if (price == -1 || price + s > c[i]) {
            price = c[i];
        } else {
            price += s;
        }
//        out << price << " * " << p[i] << endl;
        result += (long long)price * p[i];
    }
    return result;
}

int main()
{
    read();
    out << solve();
}