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 Maximum Sum of Building Speed problem solution

YASH PAL, 31 July 202415 February 2026
In this HackerEarth Maximum Sum of Building Speed problem solution You are the king of Pensville where you have 2N workers.
 
All workers will be grouped in association of size 2,so a total of N associations have to be formed.
The building speed of the ith worker is A.
 
To make an association, you pick up 2 workers. Let the minimum building speed between both workers be x, then the association has the resultant building speed x.
 
You have to print the maximum value possible of the sum of building speeds of N associations if you make the associations optimally.
 
 
HackerEarth Maximum Sum of Building Speed problem solution

 

 

HackerEarth Maximum Sum of Building Speed problem solution.

#include <bits/stdc++.h>

using namespace std;

int a[301];

int main () {
int n, m;
cin >> m;
n = m * 2;
for (int i = 1;i <= n;i ++) {
cin >> a[i];
}
sort (a + 1, a + n + 1 );
int ans = 0;
for (int i = 1;i <= n;i += 2) {
ans += min (a[i], a[i + 1]);
}
cout << ans;
return 0;
}
 
 
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