Cod sursa(job #3126460)

Utilizator Mihai780Mihai Neagoe Mihai780 Data 6 mai 2023 17:33:45
Problema Branza Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <iostream>
#include <fstream>
#include <deque>
using namespace std;

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

deque< pair<long long,int>>b;
long long N,S,T,C,P,cost,ok;
int main()
{

   fin>>N>>S>>T;
   fin>>C>>P;

   b.push_back({C,0});
   cost+=P*b[0].first;

   for(int i=1; i<N;i++)
   {
        fin >> C >> P;
        if (b[0].second + T < i)
            b.pop_front();

        if ( S * (i - b[0].second) + b[0].first >= C)
        {
            b.pop_front();
            ok=0;
        }

        b.push_back({C, i});

        cost += P * b[0].first + S*ok*P;
        ok++;
    }

    fout << cost;

    return 0;
}