Cod sursa(job #2496062)
| Utilizator | Data | 20 noiembrie 2019 10:20:40 | |
|---|---|---|---|
| Problema | Shop | Scor | 90 |
| Compilator | cpp-64 | Status | done |
| Runda | ad_hoc | Marime | 0.64 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("shop.in");
ofstream fout("shop.out");
long long n, c, l, p, j, k, a[105], b[105], t[105];
int main()
{
fin >> n >> c >> l;
for(int i=1; i<=n; i++)
{
fin >> j >> k;
a[j]=k;
t[i]=j;
}
k=0;
while(l)
{
b[k++]=l%c;
l/=c;
}
p=b[0];
for(int i=60; i>=1; i--)
{
if(b[i]>a[i])
{
b[i-1]+=(b[i]-a[i])*c;
b[i]=a[i];
}
p+=b[i];
}
fout << p << "\n";
for(int i=1; i<=n; i++)
fout << b[t[i]] << " ";
return 0;
}
