Pagini recente » Cod sursa (job #1331340) | Cod sursa (job #2275330) | Cod sursa (job #62220) | Cod sursa (job #944048) | Cod sursa (job #2265048)
//
// main.cpp
// Branza
//
// Created by Darius Buhai on 20/10/2018.
// Copyright © 2018 Darius Buhai. All rights reserved.
//
#include <iostream>
#include <deque>
#include <fstream>
using namespace std;
ifstream fin("branza.in");
ofstream fout("branza.out");
int n, t, s, ct;
struct sapt{
int c, p, i;
};
deque<sapt> b;
void rez_branza()
{
fin>>n>>s>>t;
for(int i=0;i<n;i++)
{
sapt ns;
fin>>ns.c>>ns.p;
ns.i = i;
if(b.empty())
ct+=ns.c*ns.p;
else
{
int cc = ns.c*ns.p;
for(auto it : b)
{
int ccc = it.c*ns.p + (i-it.i)*s*ns.p;
if(ccc<cc)
cc = ccc;
}
ct+=cc;
}
b.push_back(ns);
if(i-b.front().i>=t)
b.pop_front();
}
//cout<<ct;
fout<<ct;
}
int main() {
rez_branza();
return 0;
}