Problem Link #include <iostream> #include <cmath> using namespace std; typedef long long ll; int n, m; ll a[101], b[101], c[101], d[101]; ll calculateCoconutsProduced(ll time) { ll coconutsProduced = 0; for(int i = 0; i < n; i++) { coconutsProduced += (time - a[i] >= 0) ? (time - a[i]) / b[i] + 1 : 0; } return coconutsProduced; } ll calculateCoconutsConsumed(ll time) { ll coconutsConsumed = 0; for(int i = 0; i < m; i++) { coconutsConsumed += (time - c[i] >= 0) ? (time - c[i]) / d[i] + 1 : 0; } return coconutsConsumed; } void solve(ll s, ll e) { ll endTime = e; while(s < e) { ll mid = s + (e - s + 1) / 2; ll coconutsProduced = calculateCoconutsProduced(mid); ll coconutsConsumed = calculateCoconutsConsumed(endTime - mid); if(coconutsProduced > coconutsConsumed) { e = mid - 1; } else { s = mid; } } cout << s << endl; } int main() { ll t; cin ...