Cod sursa(job #2879444)
| Utilizator | Data | 28 martie 2022 16:18:47 | |
|---|---|---|---|
| Problema | Minim2 | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <fstream>
#include <queue>
using namespace std;
ifstream fin("minim2.in");
ofstream fout("minim2.out");
int n, i, j, k, x[100001];
double a, b, goal, s;
int main()
{
fin >> n;
for (i = 1; i <= n; i++)
{
fin >> x[i];
s += x[i];
}
fin >> a >> b >> goal;
priority_queue <pair<double, int>> q;
for (i = 1; i <= n; i++)
q.push({x[i]-x[i]*a, i});
while (s > goal)
{
s -= q.top().first;
i = q.top().second;
x[i] -= q.top().first;
q.pop();
q.push({x[i]-x[i]*b, i});
k++;
}
fout << k;
return 0;
}
