Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth Leaderboard Standings problem solution

YASH PAL, 31 July 202413 February 2026
In this HackerEarth Leaderboard Standings problem solution, There were N submissions made in a programming contest containing infinite problems. Each submission earned the contestant 100 points as none of the submissions is wrong or a partial submission. You are given the details of the submissions – the username of the contestant and the time taken to solve the problem. Your task is to print the rank list according to the following rules:
 
The contestant with a higher score gets a higher rank.
If the scores are tied, then the contestant with the least sum of the time taken to solve the problems gets a higher rank.
In case of a tie in both scores and the sum of the time taken, they are ranked lexicographically according to their usernames.
 
 
HackerEarth Leaderboard Standings problem solution

 

 

HackerEarth Leaderboard Standings problem solution.

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d", &x)
#define sc(x) scanf("%c", &x)
#define sl(x) scanf("%lld", &x)
#define pl(x) printf("%lldn", x)
#define pi(x) printf("%dn", x)
#define gu getchar_unlocked
#define pu putchar_unlocked
#define setbits __builtin_popcountll
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define speed ios::sync_with_stdio(false)

struct newtype{
int score;
int time;
string name;
};
typedef struct newtype node;

vector <node> v;
map < string, pair<int, int> > m;

bool cmp(node A, node B){
if(A.score != B.score){
return A.score > B.score;
}
else if(A.time != B.time){
return A.time < B.time;
}
else{
return A.name < B.name;
}
}

int main(){
int n, i;
si(n);
for(i = 0; i < n; i++){
string s; int t;
cin>>s; si(t);
auto it = m.find(s);
if(it != m.end()){
pair<int, int> P = it -> second;
P.first += 100;
P.second += t;
m[s] = P;
}
else{
m[s] = mp(100, t);
}
}
for(auto it = m.begin(); it != m.end(); it++){
node N;
N.name = it -> first;
N.score = (it -> second).first;
N.time = (it -> second).second;
v.pb(N);
}
sort(v.begin(), v.end(), cmp);
for(i = 0; i < v.size(); i++){
cout<<i + 1<<" "<<v[i].name<<endl;
}
}
 
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes