Mai intai trebuie sa te autentifici.
Cod sursa(job #2732386)
Utilizator | Data | 28 martie 2021 22:17:46 | |
---|---|---|---|
Problema | Branza | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("branza.in");
ofstream fout ("branza.out");
int main()
{
long long n, s, t, i, total = 0;
fin >> n >> s >> t;
long long c[n+5], p, deq[n+5];
long long frontt = 1, backk = 0;
for (i = 0; i <n ; i++)
{
fin >> c[i] >> p;
if(frontt <= backk && (deq[frontt] == i - t - 1))
frontt++;
while(frontt <= backk && c[i] <= c[deq[backk]] + s* (i - deq[backk]))
backk--;
deq[++backk] = i;
total += (long long)p*(c[deq[frontt]] + s*(i- deq[frontt]));
}
fout << total;
return 0;
}