Cod sursa(job #2642763)

Utilizator brunomalettaBruno Maletta Monteiro brunomaletta Data 17 august 2020 06:04:02
Problema Ghiozdan Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <bits/stdc++.h>

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main() { _
	double t;
	int n;
	cin >> t >> n;
	multiset<pair<double, int>> se;
	while (n--) {
		double x; cin >> x;
		se.insert({-x, 1});
	}
	int ans = 0;
	while (1) {
		auto it = se.begin();
		double mi = -se.rbegin()->f, ma = -it->f;
		if (mi > ma*t+1e-9) break;
		pair<double, int> novo = {it->f * it->s / (it->s+1), it->s+1};
		se.erase(it);
		se.insert(novo);
		ans++;
	}
	cout << ans << endl;
	exit(0);
}