public static void main (String[] args) throws java.lang.Exception
{
int tes=1;
lable:while(tes-->0)
{
int n=sc.nextInt(),i,idx=0;
long val[]=new long[n+1];
for(i=1;i<=n;i++) val[i]=sc.nextLong();
ArrayList<ArrayList<Integer>> arr=new ArrayList<>();
for(i=0;i<=n;i++) arr.add(new ArrayList<>());
long dp[]=new long[n+1];
dp[1]=val[1];
for(i=1;i<n;i++)
{
int x=sc.nextInt(),y=sc.nextInt();
arr.get(x).add(y);
arr.get(y).add(x);
}
dfs(arr,1,0,val); long max=0,min=0; boolean flag[]=new boolean[n+1];
for(i=1;i<=n;i++)
{
if(arr.get(i).size()==1 && max<val[i])
{
max=val[i]; flag[i]=true; flag[idx]=false; idx=i;
}
}
for(i=2;i<=n;i++)
{
if(!flag[i]) min=Math.max(min,val[i]);
}
System.out.println(max+min);
}
}
public static void dfs(ArrayList<ArrayList<Integer>> arr,int u,int p,long a[])
{
for(int it:arr.get(u))
{
if(it==p) continue;
a[it]+=a[u];
}
}
De Shawโ
(Java8)
{
int tes=1;
lable:while(tes-->0)
{
int n=sc.nextInt(),i,idx=0;
long val[]=new long[n+1];
for(i=1;i<=n;i++) val[i]=sc.nextLong();
ArrayList<ArrayList<Integer>> arr=new ArrayList<>();
for(i=0;i<=n;i++) arr.add(new ArrayList<>());
long dp[]=new long[n+1];
dp[1]=val[1];
for(i=1;i<n;i++)
{
int x=sc.nextInt(),y=sc.nextInt();
arr.get(x).add(y);
arr.get(y).add(x);
}
dfs(arr,1,0,val); long max=0,min=0; boolean flag[]=new boolean[n+1];
for(i=1;i<=n;i++)
{
if(arr.get(i).size()==1 && max<val[i])
{
max=val[i]; flag[i]=true; flag[idx]=false; idx=i;
}
}
for(i=2;i<=n;i++)
{
if(!flag[i]) min=Math.max(min,val[i]);
}
System.out.println(max+min);
}
}
public static void dfs(ArrayList<ArrayList<Integer>> arr,int u,int p,long a[])
{
for(int it:arr.get(u))
{
if(it==p) continue;
a[it]+=a[u];
}
}
De Shawโ
(Java8)
Median Path (Google) โ
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Median
{
priority_queue<int> max_heap;
priority_queue<int, vector<int>, greater<int>> min_heap;
void add(int x)
{
if (max_heap.empty() || x <= max_heap.top())
max_heap.push(x);
else
min_heap.push(x);
if (max_heap.size() > min_heap.size() + 1)
{
min_heap.push(max_heap.top());
max_heap.pop();
}
else if (min_heap.size() > max_heap.size())
{
max_heap.push(min_heap.top());
min_heap.pop();
}
}
int get()
{
return max_heap.top();
}
};
void solve()
{
int n;
cin >> n;
vector<int> a(n);
for (auto &x : a)
cin >> x;
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++)
{
int u, v;
cin >> u >> v, u--, v--;
g[u].push_back(v);
g[v].push_back(u);
}
oset<pair<int, int>> s;
long ans = 0;
function<void(int, int, int)> dfs = [&](int u, int p, int d)
{
s.insert({a[u], u});
if (d & 1)
ans += s.find_by_order((d - 1) / 2)->first;
for (auto v : g[u])
if (v != p)
dfs(v, u, d + 1);
s.erase({a[u], u});
};
dfs(0, -1, 1);
cout << ans << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--)
solve();
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct Median
{
priority_queue<int> max_heap;
priority_queue<int, vector<int>, greater<int>> min_heap;
void add(int x)
{
if (max_heap.empty() || x <= max_heap.top())
max_heap.push(x);
else
min_heap.push(x);
if (max_heap.size() > min_heap.size() + 1)
{
min_heap.push(max_heap.top());
max_heap.pop();
}
else if (min_heap.size() > max_heap.size())
{
max_heap.push(min_heap.top());
min_heap.pop();
}
}
int get()
{
return max_heap.top();
}
};
void solve()
{
int n;
cin >> n;
vector<int> a(n);
for (auto &x : a)
cin >> x;
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++)
{
int u, v;
cin >> u >> v, u--, v--;
g[u].push_back(v);
g[v].push_back(u);
}
oset<pair<int, int>> s;
long ans = 0;
function<void(int, int, int)> dfs = [&](int u, int p, int d)
{
s.insert({a[u], u});
if (d & 1)
ans += s.find_by_order((d - 1) / 2)->first;
for (auto v : g[u])
if (v != p)
dfs(v, u, d + 1);
s.erase({a[u], u});
};
dfs(0, -1, 1);
cout << ans << '\n';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--)
solve();
}
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
PnG is hiring for various roles
For 2022/2023/2024/2025 Grads
Women in Tech hiring
https://www.pgcareers.com/global/en/job/R000082789/Women-in-Tech-2023?s=08
For 2022/2023/2024/2025 Grads
Women in Tech hiring
https://www.pgcareers.com/global/en/job/R000082789/Women-in-Tech-2023?s=08
๐1
Anyone exam Oracle OA on tomorrow ?
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company name: Uber
Role: SWE Intern
Batch: 2024
Location: Bangalore
Apply: https://university-uber.icims.com/jobs/123523/job
Role: SWE Intern
Batch: 2024
Location: Bangalore
Apply: https://university-uber.icims.com/jobs/123523/job
๐1
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m, k, x, y;
cin >> n >> m >> k >> x >> y;
bool can_escape = true;
for (int i = 0; i < k; i++) {
int xi, yi;
cin >> xi >> yi;
int dx = abs(x - xi);
int dy = abs(y - yi);
if ((dx + dy) % 2 == 0) { // if Vika and friend are in same type of room
can_escape = false;
}
}
if (can_escape) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
Codeforces Aโ
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m, k, x, y;
cin >> n >> m >> k >> x >> y;
bool can_escape = true;
for (int i = 0; i < k; i++) {
int xi, yi;
cin >> xi >> yi;
int dx = abs(x - xi);
int dy = abs(y - yi);
if ((dx + dy) % 2 == 0) { // if Vika and friend are in same type of room
can_escape = false;
}
}
if (can_escape) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
Codeforces Aโ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Please find latest Opportunities from Career page and Apply before Expired before applying kindly follow jobs description and eligibility carefully
passout year: 2023, 2022, 2021, 2020, 2019, 2018
Turing Hiring Frontend Developer ( Work from home)
Apply now : https://www.turing.com/remote-developer-jobs/j/li-promoted/front-end-engineer-134757-in?
MasterCard Hiring Software Engineer
Apply now: https://careers.mastercard.com/us/en/job/R-197293/Software-Engineer
Webomates Hiring Manul tester ( Work From home)
Apply now: https://www.webomates.com/manual-testing-engineer-3/
IBM Hiring Application Developers
Apply now : https://careers.ibm.com/job/18010338/application-developer-content-courseware-design-pune-in/
Tech Mahindra Hiring For Multiple Role
Apply now : https://registration.techmahindra.com/Candidate/RegDefault.aspx
Cornerstone Hiring For DevOps Engineer
Apply now: https://cornerstone.csod.com/ux/ats/careersite/2/home/requisition/8487
Citibank Hiring For Salesforce Developer
Apply now: https://jobs.citi.com/job/-/-/287/51626977392?
Parallel Hiring Junior Software Engineer
Apply now: https://jobs.lever.co/parallelwireless/d5392784-452b-4256-a1a1-80295828fd1a?
EY Hiring Manul tester
Apply now: https://careers.ey.com/ey/job/Tester/951240901
Schneider Electric Hiring Data Analyst
Apply now: https://careers.se.com/global/jobs/008J93?
GSK Hiring Junior Programmer
Apply now: https://jobs.gsk.com/en-gb/jobs/370251?
Deloitte Hiring Data Analyst
Apply now: https://usijobs.deloitte.com/careersUSI/JobDetail/USI-EH24-MF-ITS-CA-Off-Campus-Analyst/147196
Comcast Hiring SDE1
Apply now: https://jobs.comcast.com/jobs/description/regular?external_or_internal=External&job_id=R367806
Capgemini Hiring Service Desk Analyst
Apply now: https://www.capgemini.com/jobs/O17eRIkB_6fKCuLHYU9F/service-desk-analyst--1-to-3-years--mumbai/
passout year: 2023, 2022, 2021, 2020, 2019, 2018
Turing Hiring Frontend Developer ( Work from home)
Apply now : https://www.turing.com/remote-developer-jobs/j/li-promoted/front-end-engineer-134757-in?
MasterCard Hiring Software Engineer
Apply now: https://careers.mastercard.com/us/en/job/R-197293/Software-Engineer
Webomates Hiring Manul tester ( Work From home)
Apply now: https://www.webomates.com/manual-testing-engineer-3/
IBM Hiring Application Developers
Apply now : https://careers.ibm.com/job/18010338/application-developer-content-courseware-design-pune-in/
Tech Mahindra Hiring For Multiple Role
Apply now : https://registration.techmahindra.com/Candidate/RegDefault.aspx
Cornerstone Hiring For DevOps Engineer
Apply now: https://cornerstone.csod.com/ux/ats/careersite/2/home/requisition/8487
Citibank Hiring For Salesforce Developer
Apply now: https://jobs.citi.com/job/-/-/287/51626977392?
Parallel Hiring Junior Software Engineer
Apply now: https://jobs.lever.co/parallelwireless/d5392784-452b-4256-a1a1-80295828fd1a?
EY Hiring Manul tester
Apply now: https://careers.ey.com/ey/job/Tester/951240901
Schneider Electric Hiring Data Analyst
Apply now: https://careers.se.com/global/jobs/008J93?
GSK Hiring Junior Programmer
Apply now: https://jobs.gsk.com/en-gb/jobs/370251?
Deloitte Hiring Data Analyst
Apply now: https://usijobs.deloitte.com/careersUSI/JobDetail/USI-EH24-MF-ITS-CA-Off-Campus-Analyst/147196
Comcast Hiring SDE1
Apply now: https://jobs.comcast.com/jobs/description/regular?external_or_internal=External&job_id=R367806
Capgemini Hiring Service Desk Analyst
Apply now: https://www.capgemini.com/jobs/O17eRIkB_6fKCuLHYU9F/service-desk-analyst--1-to-3-years--mumbai/
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Newton School
Role: DSA Problem Setter
Batch eligible: 2023, 2024 and 2025 grads.
Apply: https://www.linkedin.com/jobs/view/3662547139
Role: DSA Problem Setter
Batch eligible: 2023, 2024 and 2025 grads.
Apply: https://www.linkedin.com/jobs/view/3662547139
Linkedin
Newton School hiring Technical Content Engineer Intern ( DSA - Problem Setter ) in Bengaluru, Karnataka, India | LinkedIn
Posted 7:32:11 AM. ABOUT NEWTON SCHOOL Come be part of a rocketship thatโs creating a massive impact in the world ofโฆ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)
Razorpay POS is inviting Applications for Product Development Engineering Roles
Experience : 3 - 7 years
Apply link:
https://docs.google.com/forms/d/e/1FAIpQLSesI1LTpA0l9JP1cUvz2ZoXSiUJRnwerhHMRdXC1kYWp8YxQg/viewform
Experience : 3 - 7 years
Apply link:
https://docs.google.com/forms/d/e/1FAIpQLSesI1LTpA0l9JP1cUvz2ZoXSiUJRnwerhHMRdXC1kYWp8YxQg/viewform
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Monotype is Hiring for Software Engineer Trainee
Batch: 2023
Apply here-
https://monotype.wd1.myworkdayjobs.com/en-US/Monotype/job/Noida/Software-Engineer-Trainee_R0003107
Batch: 2023
Apply here-
https://monotype.wd1.myworkdayjobs.com/en-US/Monotype/job/Noida/Software-Engineer-Trainee_R0003107
Anyone Give Uber OA Today?
๐4
vector<long long>solution(int t,vector<vector<long long>>carPrices){
vector<long long>ans;
for(int i=0;i<t;i++){
vector<long long>arr=carPrices[i];
long long val = 0;
long long mx = INT_MIN;
int N=arr.size();
for (int i = 0; i < N; i++) {
long long curr = arr[i];
mx = max(mx, curr);
val = max(val, mx - curr);
}
long long res = 0;
while ((1LL << res) - 1 < val) {
++res;
}
cout<<res<<endl;
ans.push_back(res);
}
return ans;
}
Uber โ (Car)
vector<long long>ans;
for(int i=0;i<t;i++){
vector<long long>arr=carPrices[i];
long long val = 0;
long long mx = INT_MIN;
int N=arr.size();
for (int i = 0; i < N; i++) {
long long curr = arr[i];
mx = max(mx, curr);
val = max(val, mx - curr);
}
long long res = 0;
while ((1LL << res) - 1 < val) {
++res;
}
cout<<res<<endl;
ans.push_back(res);
}
return ans;
}
Uber โ (Car)
5_6174896634900515685.pdf
336.4 KB
Microsoft OA Material with Codesโ
#include<bits/stdc++.h>
typedef double C;
typedef complex<C> P;
#define X real()
#define Y imag()
P a[205];
int n, x, y, k;
bool check(int r){
int c=0;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
P g = a[j] - a[i];
double d = abs(g);
if(d > 2*r) continue;
P mid = (a[i] + a[j]) * (1.0/2);
double h = sqrt(r*1.0*r - d*d/4);
P per = P(-g.Y,g.X) * (h/d);
int c1 = 2, c2 = 2;
for(int l = 0; l < n; l++){
if(l == i or l == j) continue;
if(abs(a[l] - (mid-per)) <= r)
c1++;
if(abs(a[l] - (mid+per)) <= r)
c2++;
}
c=max({c,c1,c2});
}
}
return c>=k;
}
int Solution::solve(vector<vector<int> > &A, int B ) {
n = A.size();
for(int i = 0; i < n;i++)
a[i] = {1.0*A[i][0], 1.0*A[i][1]};
k = B;
int l = 1, h = 2000000000, ans;
while(h >= l){
int m = (l+h)/2;
if(check(m)) {
ans = m;
h = m-1;
}
else l = m+1;
}
return ans;
}
Red Zone
Media. Net โ
typedef double C;
typedef complex<C> P;
#define X real()
#define Y imag()
P a[205];
int n, x, y, k;
bool check(int r){
int c=0;
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++){
P g = a[j] - a[i];
double d = abs(g);
if(d > 2*r) continue;
P mid = (a[i] + a[j]) * (1.0/2);
double h = sqrt(r*1.0*r - d*d/4);
P per = P(-g.Y,g.X) * (h/d);
int c1 = 2, c2 = 2;
for(int l = 0; l < n; l++){
if(l == i or l == j) continue;
if(abs(a[l] - (mid-per)) <= r)
c1++;
if(abs(a[l] - (mid+per)) <= r)
c2++;
}
c=max({c,c1,c2});
}
}
return c>=k;
}
int Solution::solve(vector<vector<int> > &A, int B ) {
n = A.size();
for(int i = 0; i < n;i++)
a[i] = {1.0*A[i][0], 1.0*A[i][1]};
k = B;
int l = 1, h = 2000000000, ans;
while(h >= l){
int m = (l+h)/2;
if(check(m)) {
ans = m;
h = m-1;
}
else l = m+1;
}
return ans;
}
Red Zone
Media. Net โ