Cod sursa(job #2731907)
| Utilizator | Data | 28 martie 2021 15:10:00 | |
|---|---|---|---|
| Problema | Branza | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <iostream>
#include<fstream>
#include<deque>
#include<vector>
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;
deque<int> P;
int main()
{
f>>N>>S>>T;
for(i=0;i<T-1;i++)
{
f>>x>>y;
s=s+x*y;
}
ok=1;
for(i=T-1;i<N;i++)
{
f>>x>>y;
if(ok==1)
{
b=x;
ok=0;
}
P.push_front(y);
}
a=P.back();
P.pop_back();
while(!P.empty())
{
nr=nr+P.front();
s=s+S*nr;
P.pop_front();
}
a=a+nr;
s=s+a*b;
g<<s;
return 0;
}
