Cod sursa(job #3287927)
Utilizator | Data | 19 martie 2025 20:47:39 | |
---|---|---|---|
Problema | Branza | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("branza.in");
ofstream out("branza.out");
deque<pair<int,int>> q;
int n,s,t,i;
int x,y,sm;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
in>>n>>s>>t;
for(i=1;i<=n;++i)
{
in>>x>>y;
while(!q.empty()&& q.front().second<i-t)
q.pop_front();
while(!q.empty() && q.back().first+s*(i-q.back().second)>=x)
q.pop_back();
q.push_back({x,i});
sm+=y*(q.front().first+s*(i-q.front().second));
}
out<<sm;
}