#include <bits/stdc++.h>
using namespace std;
struct Fenwick {
int n;
vector<int> b;
Fenwick(int n) : n(n), b(n + 1, INT_MAX) {}
void update(int i, int v) {
for (; i <= n; i += i & -i)
b[i] = min(b[i], v);
}
int query(int i) {
int r = INT_MAX;
for (; i > 0; i -= i & -i)
r = min(r, b[i]);
return r;
}
};
vector<int> findStarvation(vector<long long>& priorities) {
int n = priorities.size();
vector<int> ans(n, 0);
vector<long long> c = priorities;
sort(c.begin(), c.end());
c.erase(unique(c.begin(), c.end()), c.end());
auto id = [&](long long x) {
return int(lower_bound(c.begin(), c.end(), x) - c.begin()) + 1;
};
Fenwick f(c.size());
for (int i = n - 1; i >= 0; i--) {
int p = id(priorities[i]);
int j = f.query(p - 1);
ans[i] = (j == INT_MAX ? 0 : j - i);
f.update(p, i);
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n)) return 0;
vector<long long> priorities(n);
for (int i = 0; i < n; i++)
cin >> priorities[i];
vector<int> res = findStarvation(priorities);
for (int i = 0; i < n; i++) {
if (i) cout << ' ';
cout << res[i];
}
cout << '\n';
return 0;
}
Successfully Cleared IBM- CIC - ASE â
test accomplished â¤ī¸ || plagfree coding â
DM for any placement Help
@Mrtrueliving_ix
@Mrtrueliving_ix
đ¯ Test Clearance Guarantee
đĨ High-end Excellence delivered, not promised
https://t.me/Code_alphix/9315?single
Please open Telegram to view this post
VIEW IN TELEGRAM
All set for Cognizant ONCAMPUS â
DM for any placement Help available
@Mrtrueliving_ix
@Mrtrueliving_ix
=> 3pm ONCAMPUS Slots are available
Cognizant ONCAMPUS HELP â ||10AM
Test accomplished â¤ī¸ || Java {3}
DM for Any placement Help
@Mrtrueliving_ix @Mrtrueliving_ix
#Cts #ONCAMPUS #R3 #2026_Batch
https://t.me/Code_alphix/9119?single
â¤2đž2đĢĄ1
CTS 2026
BE BTECH ME MTECH
check eligibility and apply
https://app.joinsuperset.com/join/#/signup/student?jp=646c344f-7e0c-4d40-aef8-3b3fc8430245
Check your eligibility criteria to apply ASAP
BE BTECH ME MTECH
check eligibility and apply
https://app.joinsuperset.com/join/#/signup/student?jp=646c344f-7e0c-4d40-aef8-3b3fc8430245
Check your eligibility criteria to apply ASAP
â¤1
INFOSYS SLOTS-ARE AVAILABLE âī¸
https://t.me/Code_alphix/9199
https://t.me/Code_alphix/9209?single
https://t.me/Code_alphix/9194?single
https://t.me/Code_alphix/8086
https://t.me/Code_alphix/7455
https://t.me/Code_alphix/7408
https://t.me/Code_alphix/7650
đŦ DM for 100% Placement Offers:
đ @Mrtrueliving_ix
đ @Mrtrueliving_ix
https://t.me/Code_alphix/9199
https://t.me/Code_alphix/9209?single
https://t.me/Code_alphix/9194?single
https://t.me/Code_alphix/8086
https://t.me/Code_alphix/7455
https://t.me/Code_alphix/7408
https://t.me/Code_alphix/7650
đŦ DM for 100% Placement Offers:
đ @Mrtrueliving_ix
đ @Mrtrueliving_ix
Please open Telegram to view this post
VIEW IN TELEGRAM
â¤1
Successfully cleared Cognizant đĨŗ
SHORTLISTED FOR INTERVIEW đĨŗđ
GenC proâ¤ī¸ || GenC Next đ
DM those Who need đ¯ test Clearance.
@Mrtrueliving_ix || @Mrtrueliving_ix
#Cognizant #JavaTrack #GenC #GencNext #Offcampus
Helping proof :
https://t.me/Code_alphix/9327?single
All 3 rounds help done â with đ¯
@Mrtrueliving_ix @Mrtrueliving_ix
SHORTLISTED FOR INTERVIEW đĨŗđ
GenC proâ¤ī¸ || GenC Next đ
=>#Java_track đ
DM those Who need đ¯ test Clearance.
@Mrtrueliving_ix || @Mrtrueliving_ix
#Cognizant #JavaTrack #GenC #GencNext #Offcampus
Helping proof :
https://t.me/Code_alphix/9327?single
All 3 rounds help done â with đ¯
Communication + Aptitude + technical
Only plagfree coding đ
@Mrtrueliving_ix @Mrtrueliving_ix
Results speak louder than hype.đđ
All placement exams & interview Help available
@Mrtrueliving_ix
@Mrtrueliving_ix
Those who are looking for a top notch success DM now
đ Accenture Offcampus â All Set!
Login credentials will be shared very soon âŗ
Stay confident and give your best đ¯
⨠All the best everyone! â¨
đ @Mrtrueliving_ix
Login credentials will be shared very soon âŗ
Stay confident and give your best đ¯
⨠All the best everyone! â¨
đ @Mrtrueliving_ix
â¤2
Company:Zensar
Batches: 2022 to 2026
Apply link:
https://forms.office.com/pages/responsepage.aspx?id=Mj58IBVx006KVSL37bd9ybeqpIAtYiJKvHTQhHsYIn5UQUlMQjdGWjRCOE9KMFY1WVc3Uk5INlFRMS4u&route=shorturl
Batches: 2022 to 2026
Apply link:
https://forms.office.com/pages/responsepage.aspx?id=Mj58IBVx006KVSL37bd9ybeqpIAtYiJKvHTQhHsYIn5UQUlMQjdGWjRCOE9KMFY1WVc3Uk5INlFRMS4u&route=shorturl
:
đ Infosys Technical Assessment â On-Campus Drive
đ Date: 16th December 2025
Dear Students,
Infosys will be conducting a Technical Assessment on campus on 16-12-2025.
đ All registered students must compulsorily attend, even if already placed in other organizations.
As instructed by the Dean â Training & Placements, participation is mandatory since this drive includes opportunities for higher compensation roles.
đ§ Assessment Pattern
Total Questions: 4
(Simple | Moderate | Hard | Complex)
Attempt: Any 3 Questions
Time Duration: 3 Hours
đ Role Shortlisting Criteria
âī¸ Simple level solved â DSE Role
âī¸ Moderate level solved â L1 â SP Role (âš10 LPA)
âī¸ Hard level solved â L1 â SP Role (âš16 LPA)
âī¸ Complex level solved â L3 â SP Role (âš21 LPA)
(Passing a few test cases in other questions is required in all cases)
âšī¸ Important Note:
The difficulty level is aligned with the current university curriculum, not IIT/IIIT standards.
đĸ Prepare thoroughly and ensure your presence on the assessment day.
đŠ DM for 100% test clearance: @Mrtrueliving_ixđ
đ Infosys Technical Assessment â On-Campus Drive
đ Date: 16th December 2025
Dear Students,
Infosys will be conducting a Technical Assessment on campus on 16-12-2025.
đ All registered students must compulsorily attend, even if already placed in other organizations.
As instructed by the Dean â Training & Placements, participation is mandatory since this drive includes opportunities for higher compensation roles.
đ§ Assessment Pattern
Total Questions: 4
(Simple | Moderate | Hard | Complex)
Attempt: Any 3 Questions
Time Duration: 3 Hours
đ Role Shortlisting Criteria
âī¸ Simple level solved â DSE Role
âī¸ Moderate level solved â L1 â SP Role (âš10 LPA)
âī¸ Hard level solved â L1 â SP Role (âš16 LPA)
âī¸ Complex level solved â L3 â SP Role (âš21 LPA)
(Passing a few test cases in other questions is required in all cases)
âšī¸ Important Note:
The difficulty level is aligned with the current university curriculum, not IIT/IIIT standards.
đĸ Prepare thoroughly and ensure your presence on the assessment day.
đŠ DM for 100% test clearance: @Mrtrueliving_ix
Please open Telegram to view this post
VIEW IN TELEGRAM
â¤1đ1đ1