Buzz Sale
C++
TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9
#include
#include
#include
using namespace std;
https://telegram.me/PLACEMENTLELO
int main() {
int n;
cin >> n;
// @PLACEMENTLELO
vector 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
C++
TCS CodeVita Zone 2
https://telegram.me/+_hn3cBQVbGliYTI9
#include
#include
#include
using namespace std;
https://telegram.me/PLACEMENTLELO
int main() {
int n;
cin >> n;
// @PLACEMENTLELO
vector 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