CodeForces Binary Search EDU -Children Holiday

Problem link:
Children Holiday

#include <bits/stdc++.h>
using namespace std;
long long countInflated(vector<int> &eachb, vector<int> &streak, vector<int> &rest, int time, vector<int> &work, int req) {
	int n = eachb.size();
	int total = 0, curr = 0, maxc = 0;
	// cout << "ind report " << " ";
	for (int i = 0; i < n; i++) {
		maxc = (eachb[i] * streak[i]) + rest[i];
		curr = (time / maxc) * streak[i];
		total += curr;
		// cout << i << " " << "work " << curr << "; ";
		work[i] = curr;
	}
	for (int i = 0; i < n; i++) {
		maxc = (eachb[i] * streak[i]) + rest[i];
		if (total < req) {
			work[i] += min((time % maxc) / eachb[i], streak[i]);
			curr += min((time % maxc) / eachb[i], streak[i]);
			total += min((time % maxc) / eachb[i], streak[i]);
		} else {
			break;
		}

	}

	// cout << "\n";
	return total;

}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int m, n, slowestworkertime = 0;
	cin >> m >> n;
	vector<int> eachb(n, 0);
	/**
	 * Max ballons can be inflated at
	 * each session
	 */
	vector<int> sessionb(n, 0);
	vector<int> relaxt(n, 0);
	vector<int> record(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> eachb[i] >> sessionb[i] >> relaxt[i];
		slowestworkertime = max(slowestworkertime, eachb[i]);
	}
	int low = 1, high = slowestworkertime * m, mid = 0;
	long long inflated = 0, ans = 0;
	vector<int> samp(n, 0);
	while (low <= high) {
		mid = low + (high - low) / 2;
		inflated = countInflated(eachb, sessionb, relaxt, mid, samp, m);
		// cout << "Report " << mid << " time " << inflated << "\n";
		if (inflated >= m) {
			ans = mid;
			record = samp;
			high = mid - 1;
		} else {
			low = mid + 1;
		}
	}
	cout << ans << "\n";
	for (int i = 0; i < n; i++) {
		cout << record[i] << " ";
	}
	cout << "\n";
	return 0;
}

Can anyone please explain what is the wrong with the approach.Struck with the problem.