#include <iostream>
#include <vector>
#include <functional>
#include <array>
using namespace std;
using ll = long long;
ll maxValue(ll a, ll b) {
return (a > b) ? a : b;
}
int getMinServers(int n, vector<int> f, vector<int> t, vector<int> w, vector<int> v) {
vector<ll> size(n), maxDistance(n);
vector<vector<array<ll, 2>>> adjacencyList(n);
for (ll i = 0; i < f.size(); i++) {
f[i]--;
t[i]--;
adjacencyList[f[i]].push_back({t[i], w[i]});
adjacencyList[t[i]].push_back({f[i], w[i]});
}
ll answer = 0;
function<void(ll, ll)> dfs1 = [&](ll u, ll parent) {
size[u] = 1;
ll idx = 0;
while (idx < adjacencyList[u].size()) {
ll vertex = adjacencyList[u][idx][0];
ll weight = adjacencyList[u][idx][1];
if (vertex != parent) {
maxDistance[vertex] = maxValue(maxDistance[u] + weight, weight);
dfs1(vertex, u);
size[u] += size[vertex];
}
idx++;
}
};
function<void(ll, ll)> dfs2 = [&](ll u, ll parent) {
if (u != 0 && maxDistance[u] > v[u]) {
answer += size[u];
} else {
ll idx = 0;
while (idx < adjacencyList[u].size()) {
ll vertex = adjacencyList[u][idx][0];
if (vertex != parent) {
dfs2(vertex, u);
}
idx++;
}
}
};
dfs1(0, -1);
dfs2(0, -1);
return answer;
}
Cisco โ
Minserver
๐3
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int solve(int i, vector<int>& lst, int ad, const vector<int>& machineCount, const vector<int>& finalMachineCount, int shiftingCost) {
int n = machineCount.size();
if (i == n) {
int res = ad;
for (int k = 0; k < 3; ++k) {
res += abs(lst[k] - finalMachineCount[k]);
}
return res;
}
int res = INT_MAX;
res = min(res, solve(i + 1, lst, ad, machineCount, finalMachineCount, shiftingCost));
for (int j = 0; j < 3; ++j) {
lst[j] += machineCount[i];
if (lst[j] - machineCount[i] != 0) {
res = min(res, solve(i + 1, lst, ad + shiftingCost, machineCount, finalMachineCount, shiftingCost));
} else {
res = min(res, solve(i + 1, lst, ad, machineCount, finalMachineCount, shiftingCost));
}
lst[j] -= machineCount[i];
}
return res;
}
int getMinimumCost(const vector<int>& machineCount, const vector<int>& finalMachineCount, int shiftingCost) {
vector<int> lst(3, 0);
return solve(0, lst, 0, machineCount, finalMachineCount, shiftingCost);
}
GetMinimum Costโ
Cisco
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int solve(int i, vector<int>& lst, int ad, const vector<int>& machineCount, const vector<int>& finalMachineCount, int shiftingCost) {
int n = machineCount.size();
if (i == n) {
int res = ad;
for (int k = 0; k < 3; ++k) {
res += abs(lst[k] - finalMachineCount[k]);
}
return res;
}
int res = INT_MAX;
res = min(res, solve(i + 1, lst, ad, machineCount, finalMachineCount, shiftingCost));
for (int j = 0; j < 3; ++j) {
lst[j] += machineCount[i];
if (lst[j] - machineCount[i] != 0) {
res = min(res, solve(i + 1, lst, ad + shiftingCost, machineCount, finalMachineCount, shiftingCost));
} else {
res = min(res, solve(i + 1, lst, ad, machineCount, finalMachineCount, shiftingCost));
}
lst[j] -= machineCount[i];
}
return res;
}
int getMinimumCost(const vector<int>& machineCount, const vector<int>& finalMachineCount, int shiftingCost) {
vector<int> lst(3, 0);
return solve(0, lst, 0, machineCount, finalMachineCount, shiftingCost);
}
GetMinimum Costโ
Cisco
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int SS(const string& rollNumber) {
int num = 0;
for (char c : rollNumber) {
if (isdigit(c)) {
num = num * 10 + (c - '0');
}
}
return num;
}
bool compare(const pair<string, int>& a, const pair<string, int>& b) {
string classA = "", classB = "";
int numA = SS(a.first);
int numB = SS(b.first);
for (char c : a.first) {
if (isalpha(c)) classA += c;
else break;
}
for (char c : b.first) {
if (isalpha(c)) classB += c;
else break;
}
if (classA == classB) return numA < numB;
return classA < classB;
}
int main() {
int N;
cin >> N;
vector<pair<string, int>> students(N);
for (int i = 0; i < N; ++i) {
cin >> students[i].first >> students[i].second;
}
sort(students.begin(), students.end(), compare);
for (const auto& student : students) {
cout << student.first << " " << student.second << endl;
}
return 0;
}
CBX(intern)โ
#include <vector>
#include <algorithm>
using namespace std;
int SS(const string& rollNumber) {
int num = 0;
for (char c : rollNumber) {
if (isdigit(c)) {
num = num * 10 + (c - '0');
}
}
return num;
}
bool compare(const pair<string, int>& a, const pair<string, int>& b) {
string classA = "", classB = "";
int numA = SS(a.first);
int numB = SS(b.first);
for (char c : a.first) {
if (isalpha(c)) classA += c;
else break;
}
for (char c : b.first) {
if (isalpha(c)) classB += c;
else break;
}
if (classA == classB) return numA < numB;
return classA < classB;
}
int main() {
int N;
cin >> N;
vector<pair<string, int>> students(N);
for (int i = 0; i < N; ++i) {
cin >> students[i].first >> students[i].second;
}
sort(students.begin(), students.end(), compare);
for (const auto& student : students) {
cout << student.first << " " << student.second << endl;
}
return 0;
}
CBX(intern)โ
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool canRobAll(const vector<int>& houses, int H, int K) {
int hours_needed = 0;
for (int house_count : houses) {
hours_needed += (house_count + K - 1) / K; // Ceiling division
}
return hours_needed <= H;
}
int main() {
int N, H;
cin >> N >> H;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int left = 1;
int right = *max_element(A.begin(), A.end());
while (left < right) {
int mid = left + (right - left) / 2;
if (canRobAll(A, H, mid)) {
right = mid;
} else {
left = mid + 1;
}
}
cout << left << endl;
return 0;
}
//Richies World
Flipkartโ
#include <vector>
#include <algorithm>
using namespace std;
bool canRobAll(const vector<int>& houses, int H, int K) {
int hours_needed = 0;
for (int house_count : houses) {
hours_needed += (house_count + K - 1) / K; // Ceiling division
}
return hours_needed <= H;
}
int main() {
int N, H;
cin >> N >> H;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int left = 1;
int right = *max_element(A.begin(), A.end());
while (left < right) {
int mid = left + (right - left) / 2;
if (canRobAll(A, H, mid)) {
right = mid;
} else {
left = mid + 1;
}
}
cout << left << endl;
return 0;
}
//Richies World
Flipkartโ
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
bool isPrime(int n)
{
if (n <= 1)
return false;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
return false;
}
return true;
}
int main()
{
int N, K;
cin >> N >> K;
if (N == 0)
{
cout << -1 << endl;
return 0;
}
vector<int> a(N);
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
vector<int> b;
for (int i = 0; i < N; i++)
{
if (isPrime(i + 1) && a[i] >= K)
{
b.push_back(a[i]);
}
}
int required = ceil(N / 3.0);
if (b.size() < required)
{
cout << -1 << endl;
return 0;
}
int ans = 0, count = N / 2, t = 0;
for (int i = 1; i <= N; i++)
{
if (a[i - 1] >= K and isPrime(i))
{
ans += a[i - 1] / 2;
count--;
if (i == 2)
t = 1;
if (i == 3 and t == 1)
{
count++;
ans -= a[i - 1] / 2;
}
}
if (count == 0)
break;
}
cout << ans << endl;
return 0;
}
juice
flipkart โ
#include <vector>
#include <cmath>
using namespace std;
bool isPrime(int n)
{
if (n <= 1)
return false;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
return false;
}
return true;
}
int main()
{
int N, K;
cin >> N >> K;
if (N == 0)
{
cout << -1 << endl;
return 0;
}
vector<int> a(N);
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
vector<int> b;
for (int i = 0; i < N; i++)
{
if (isPrime(i + 1) && a[i] >= K)
{
b.push_back(a[i]);
}
}
int required = ceil(N / 3.0);
if (b.size() < required)
{
cout << -1 << endl;
return 0;
}
int ans = 0, count = N / 2, t = 0;
for (int i = 1; i <= N; i++)
{
if (a[i - 1] >= K and isPrime(i))
{
ans += a[i - 1] / 2;
count--;
if (i == 2)
t = 1;
if (i == 3 and t == 1)
{
count++;
ans -= a[i - 1] / 2;
}
}
if (count == 0)
break;
}
cout << ans << endl;
return 0;
}
juice
flipkart โ
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> a(n), b(n);
int sumA = 0, sumB = 0;
for (auto &i : a)
cin >> i, sumA += i;
for (auto &i : b)
cin >> i, sumB += i;
int ans = min(sumA, sumB), mask = (1 << n);
for (int i = 0; i < mask; ++i)
{
int curr = 0, currentB = 0;
for (int j = 0; j < n; ++j)
{
if (i & (1 << j))
{
curr += a[j];
}
else
{
currentB += b[j];
}
}
ans = max(ans, min(curr, currentB));
}
cout << ans << endl;
return 0;
}
// game
flipkart โ
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> a(n), b(n);
int sumA = 0, sumB = 0;
for (auto &i : a)
cin >> i, sumA += i;
for (auto &i : b)
cin >> i, sumB += i;
int ans = min(sumA, sumB), mask = (1 << n);
for (int i = 0; i < mask; ++i)
{
int curr = 0, currentB = 0;
for (int j = 0; j < n; ++j)
{
if (i & (1 << j))
{
curr += a[j];
}
else
{
currentB += b[j];
}
}
ans = max(ans, min(curr, currentB));
}
cout << ans << endl;
return 0;
}
// game
flipkart โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Juspay Hiring Challenge 2024
Batch eligible: 2024 and 2025 grads
Round:
1) MCQ
2) Coding
3) Final Interview
CTC: 21-27 Lakh
Stipend: 40k per month
Apply: https://unstop.com/o/y9PvMOt?lb=Mgx4BsU&utm_medium=Share&utm_source=shortUrl
Batch eligible: 2024 and 2025 grads
Round:
1) MCQ
2) Coding
3) Final Interview
CTC: 21-27 Lakh
Stipend: 40k per month
Apply: https://unstop.com/o/y9PvMOt?lb=Mgx4BsU&utm_medium=Share&utm_source=shortUrl
Unstop
Participate in Juspay Hiring Challenge 2024 & win exciting prizes. | 1141948 // Unstop
Find out the best Juspay Hiring Challenge 2024 that match your interests. Prove your mettle and win exciting prizes like job opportunities and cash rewards f... | 2024 | 1141948
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Open Positions Available:
- Front-End Developers : Build intuitive and visually stunning web applications.
- Flutter Developers : Create cutting-edge mobile applications.
Interns : Also welcome to apply
Apply Here : https://docs.google.com/forms/d/e/1FAIpQLScxv1xGftiuF34-Z-2pXzEQWrNHP2echXw6mZnTL4O4MefZsA/viewform
- Front-End Developers : Build intuitive and visually stunning web applications.
- Flutter Developers : Create cutting-edge mobile applications.
Interns : Also welcome to apply
Apply Here : https://docs.google.com/forms/d/e/1FAIpQLScxv1xGftiuF34-Z-2pXzEQWrNHP2echXw6mZnTL4O4MefZsA/viewform
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Need SAP Certified Freshers for Quints Global | Location: Okhla, New Delhi* ๐ฅ๐ฅ๐ฅ
Positions available:
1. SAP SD Management Trainee.
2. SAP FICO Management Trainee.
3. SAP MM Management Trainee.
Qualification: BCA/ MCA/ B Tech.
Date of Interview: 5th & 6th September
Venue: Quints Global Pvt. Ltd., 3rd Floor, 12 A Pride Tower, Near Kotak Mahindra, Sector- 125, Noida, Nearest Metro: Okhla Bird Sanctuary.
Positions available:
1. SAP SD Management Trainee.
2. SAP FICO Management Trainee.
3. SAP MM Management Trainee.
Qualification: BCA/ MCA/ B Tech.
Date of Interview: 5th & 6th September
Venue: Quints Global Pvt. Ltd., 3rd Floor, 12 A Pride Tower, Near Kotak Mahindra, Sector- 125, Noida, Nearest Metro: Okhla Bird Sanctuary.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
๐ Internship Opportunity in ISRO ๐ | Steaphen Sigatapu | 541 comments
๐ Internship Opportunity in ISRO ๐
This is for all students who are looking for internship opportunities in ISRO - Indian Space Research Organization. This is an amazing opportunity to apply for internship in VSSC, ISRO.
The application for this internshipโฆ
This is for all students who are looking for internship opportunities in ISRO - Indian Space Research Organization. This is an amazing opportunity to apply for internship in VSSC, ISRO.
The application for this internshipโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Apply, if interested!!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
American Express is hiring for multiple roles
For 2022, 2023 grads
https://www.linkedin.com/posts/satvik-jain-a939b4212_apply-to-team-amex-activity-7236473446245818368-beDQ?utm_source=share&utm_medium=member_android
For 2022, 2023 grads
https://www.linkedin.com/posts/satvik-jain-a939b4212_apply-to-team-amex-activity-7236473446245818368-beDQ?utm_source=share&utm_medium=member_android
Linkedin
๐ Exciting News: American Express is Hiring for Multiple Roles!๐ | Satvik Jain | 40 comments
๐ Exciting News: American Express is Hiring for Multiple Roles!๐
Are you looking to join a dynamic team and make a significant impact? American Express is currently hiring across various roles, and I'm here to help you get your foot in the door! ๐ฆโจ
If you'reโฆ
Are you looking to join a dynamic team and make a significant impact? American Express is currently hiring across various roles, and I'm here to help you get your foot in the door! ๐ฆโจ
If you'reโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Bungee Tech is hiring SDE intern
For 2024, 2025 grads
Location: Remote
https://www.linkedin.com/jobs/view/4013961516
For 2024, 2025 grads
Location: Remote
https://www.linkedin.com/jobs/view/4013961516
Linkedin
Bungee Tech hiring Software Engineer Intern in India | LinkedIn
Posted 6:09:59 AM. Key Responsibilities: Build & maintain high tps, reliable, performant and cost-effective dataโฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
JLL Technologies is hiring for Data Engineer 1
Experience: 0 - 1 year's
Expected Salary: 10-20 LPA
Apply here: https://jll.wd1.myworkdayjobs.com/jlltcareers/job/Bengaluru-KA/Data-Engineer-1_REQ380340-1?source=APPLICANT_SOURCE-6-42
Experience: 0 - 1 year's
Expected Salary: 10-20 LPA
Apply here: https://jll.wd1.myworkdayjobs.com/jlltcareers/job/Bengaluru-KA/Data-Engineer-1_REQ380340-1?source=APPLICANT_SOURCE-6-42