LeetCode Weekly Solutions
7.28K subscribers
34 photos
11 files
101 links
Latest Jobs and Internships are regularly uploaded here : https://t.me/placementlelo

If you want any other exam answers for free : @exam_cheating_bot

Collaborations: @growth_admin
Download Telegram
Buzz Sale
C++

TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;
https://telegram.me/PLACEMENTLELO

int main() {
int n;
cin >> n;
// @PLACEMENTLELO
vector<int> ids(n), costs(n);
for (int i = 0; i < n; i++) cin >> ids[i];
for (int i = 0; i < n; i++) cin >> costs[i];

int budget;
cin >> budget;
// @PLACEMENTLELO
int mfi = 0, mfw = 0;

for (int i = 0; i < n; i++) {
int buyCost = costs[i];
int maxQty = budget / buyCost;
// @PLACEMENTLELO
if (maxQty > 0) {
int cfi = 0;
int cfw = 0;
https://telegram.me/PLACEMENTLELO

for (int j = 0; j < n; j++) {
if (i != j && ids[i] % ids[j] == 0) {
cfi += maxQty;
cfw += costs[j] * maxQty;
}
}
// @PLACEMENTLELO
if (cfi > mfi ||
(cfi == mfi && cfw > mfw)) {
mfi = cfi;
mfw = cfw;
}
}
}
// @PLACEMENTLELO
cout << mfi << " " << mfw << endl;
return 0;
}

Buzz Sale
C++

TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9