Count K-Subsequences of a String with Maximum Beauty Solution || Leetcode Bi-Weekly 112 Get link Facebook X Pinterest Email Other Apps - September 04, 2023 Count K-Subsequences of a String with Maximum Beauty Get link Facebook X Pinterest Email Other Apps
Gift Shop and Coupon Solution || Codechef Starters - 30 Get link Facebook X Pinterest Email Other Apps - March 20, 2022 Gift Shop and Coupon Solution Codechef Starters - 30Problem Code : GFTSHPProblem Link : https://www.codechef.com/START30B/problems/GFTSHPSolution :#include <bits/stdc++.h>#define ll long long int#define ull unsigned long long intusing namespace std;void solve(){ ll n, k; cin >> n >> k; ll a[n]; for (ll i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); ll ans = 0, i = 0, temp = 0; while (temp <= k && i < n) { if (a[i] + temp <= k) { ans++; temp += a[i]; i++; } else if (temp + ((a[i] + 1) / 2) <= k) { temp += (a[i] + 1) / 2; ans++; i++; break; } else { break; } } cout << ans << "\n";}int main(){ ll t; cin >> t; while (t--) { solve(); }} Get link Facebook X Pinterest Email Other Apps Comments
Exact Marks Solution || Codechef March Long Challenge 2022 - I - March 11, 2022 Exact Marks Solution Read more
Substring of a Substring Solution || Codechef March Long Challenge 2022 - I - March 11, 2022 Substring of a Substring Solution Read more
Binary Base Basics Solution || Codechef February Long Challenge 2022 - I - February 04, 2022 Binary Base Basics Solution Read more
Comments
Post a Comment