Pagini recente » Cod sursa (job #1515353) | Cod sursa (job #397933) | Cod sursa (job #1543956) | Cod sursa (job #1012471) | Cod sursa (job #3126541)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
ifstream f("branza.in");
ofstream g("branza.out");
int main()
{
int n,s,t,pret=0;
f>>n>>s>>t;
vector<pair<int,int>> v(n+1);
for(int i=1;i<=n;i++) f>>v[i].first>>v[i].second;
for(int i=1;i<=n-t;i++)
pret += v[i].first*v[i].second;
int sum_left = 0,sum_depozit = 0,total_depozit = 0;
for(int i=n-t+1;i<=n;i++) {
sum_left += v[i].second;
if(i != n-t+1) sum_depozit += v[i].second;
}
for(int i=n-t+2;i<=n;i++)
total_depozit += sum_depozit, sum_depozit -= v[i].second;
pret += v[n-t+1].first*sum_left + total_depozit*10;
g<<pret;
return 0;
}