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
Buying Sweets Solution || Codechef Starters - 36 Get link Facebook X Pinterest Email Other Apps - April 27, 2022 Buying Sweets Solution Codechef Starters - 36Problem Code : BUYSWEETProblem Link : https://www.codechef.com/START36D/problems/BUYSWEETSolution :#include <bits/stdc++.h>#define ll long long intusing namespace std;static bool mysort(vector<ll> &a, vector<ll> &b){ return a[2] <= b[2];}int main(){ ll t = 1; cin >> t; while (t--) { ll n, r; cin >> n >> r; vector<vector<ll>> a(n, vector<ll>(3, 0)); for (ll i = 0; i < n; i++) { cin >> a[i][0]; } for (ll i = 0; i < n; i++) { cin >> a[i][1]; } for (ll i = 0; i < n; i++) { a[i][2] = a[i][0] - a[i][1]; } sort(a.begin(), a.end(), mysort); ll ans = 0; for (ll i = 0; i < n; i++) { while (r && a[i][0] <= r && a[i][2] <= r) { ll temp = r / a[i][0]; ans += temp; r -= temp * a[i][2]; } } cout << ans << "\n"; }} 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