category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

C - Tsundoku, binary search, prefix sums

Code ```cpp long long int n, m, k; cin >> n >> m >> k; std ::vector arr(n), brr(m); for (int i = 0; i < n; i++) { cin >> arr[i]; arr[i] += (i > 0 ? arr[i - 1] : 0); } for (int i = 0; i < m; i++) { cin >> brr[i]; brr[i] += (i > 0 ? brr[i - 1] : 0); } long long int ans = 0; for (int i = 0; i < n; i++) { if (arr[i] > k) break; auto it = upper_bound((brr).begin(), (brr).end(), k - arr[i]); ans = max(1 + i + (ll)(it - brr.begin()), ans); } for (int i = 0; i < m; i++) { if (brr[i] > k) break; auto it = upper_bound((arr).begin(), (arr).end(), k - brr[i]); ans = max(1 + i + (ll)(it - arr.begin()), ans); } cout << ans << '\n'; ``` </details>