Cod sursa(job #2731940)

Utilizator mirunavrAvram Miruna-Alexandra mirunavr Data 28 martie 2021 15:53:58
Problema Branza Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include<fstream>
#include<deque>
#include<vector>
#include <bits/stdc++.h>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
int N,S,T,s=0,nr=0,i,x,y,b,ok=1,a;
//vector<int> C;
//vector<int> P;
int C[10000],P[10000];
deque<pair<int,int> > caut;
int main()
{
    f>>N>>S>>T;
    for(i=1;i<=N;i++)
    {
        f>>x>>y;
        //C.push_back(x);
        //P.push_back(y);

        while(!caut.empty() && ( i-caut.front().second )>T)
            caut.pop_front();

        while(!caut.empty() && x<(caut.back().first+S*(caut.back().second)))
            caut.pop_back();
        caut.push_back({x,i});
        s+=y*(caut.front().first+S * ( i - caut.front().second ));
    }
    g<<s;
}