Cod sursa(job #3126541)

Utilizator skphaMincu Adrian skpha Data 6 mai 2023 18:37:21
Problema Branza Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
#include <iostream>
#include <vector>
#include <fstream>

using namespace std;

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

int main()
{
    int n,s,t,pret=0;
    f>>n>>s>>t;
    vector<pair<int,int>> v(n+1);
    for(int i=1;i<=n;i++) f>>v[i].first>>v[i].second;

    for(int i=1;i<=n-t;i++)
        pret += v[i].first*v[i].second;

    int sum_left = 0,sum_depozit = 0,total_depozit = 0;
    for(int i=n-t+1;i<=n;i++) {
        sum_left += v[i].second;
        if(i != n-t+1) sum_depozit += v[i].second;
    }

    for(int i=n-t+2;i<=n;i++)
        total_depozit += sum_depozit, sum_depozit -= v[i].second;

    pret += v[n-t+1].first*sum_left + total_depozit*10;
    
    g<<pret;
    return 0;
}