Cod sursa(job #2360868)

Utilizator radugheoRadu Mihai Gheorghe radugheo Data 2 martie 2019 10:59:19
Problema Branza Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <bits/stdc++.h>
#define DIM 100005

using namespace std;

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

long long n, s, t, i, sol, poz, mipret, micant, can;
long long pret[DIM], cant[DIM];

int main(){
    fin >> n >> s >> t;
    mipret = INT_MAX;
    for (i=1; i<=n; i++){
        fin >> pret[i] >> cant[i];
        if (i < t){
            sol += pret[i]*cant[i];
        }
        else{
            if (pret[i] < mipret){
                mipret = pret[i];
                micant = cant[i];
                poz = i;
            }
            can += cant[i];
        }
    }
    sol += can*mipret;
    for (i=t; i<=n; i++){
        if (i != poz){
            can -= cant[i];
            sol += s*can;
        }
    }
    fout << sol;
    return 0;
}