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 The rise of the weird… things [1] problem solution

YASH PAL, 31 July 202417 February 2026
In this HackerEarth The rise of the weird… things [1] problem solution Bangalore City, where peace prevails most of the time. Not everyone is a huge fan of peace, though. Certainly not Mr. XYZ, whose identity is not known to us – yet. Mr. XYZ has somehow managed to bring vampires and zombies to Bangalore City to attack and destroy the city.
 
Fatal Eagle, an ordinary citizen of the city is extremely worried on seeing his city being attacked by these weird creatures. But, as of now, he has no power to stop these creatures from their silent attacks. He wants to analyze these creatures firstly. He figured out some things about these creatures, like:
  1. Zombies have power in terms of an EVEN number.
  2. Vampires have power in terms of an ODD number.
If he sees a zombie or a vampire, he marks them in his list with their power. After generating the entire list of power of these creatures, he decides to arrange this data in the following manner:
  • All the zombies arranged in sorted manner of their power, followed by the total power of zombies.
  • All the vampires arranged in sorted manner of their power, followed by the total power of vampires.
You’ve to help him produce the following list to help him save his city.
 
 
HackerEarth The rise of the weird... things [1] problem solution

 

 

HackerEarth The rise of the weird… things [1] problem solution.

n = int(raw_input())
l = map(int, raw_input().split())
od, ev = [], []
sod, sev = 0, 0
for i in l:
if i%2==0:
ev.append(i)
sev = sev + i
else:
od.append(i)
sod = sod + i
ev.append(sev)
od.append(sod)
ev, od = sorted(ev), sorted(od)
final = ev + od
for i in xrange(len(final)):
if i==len(final)-1:
print final[i]
else:
print final[i],
 

Second solution

#include <bits/stdc++.h>

void assert_digit() {char c = getchar(); assert('0' <= c && c <= '9'); ungetc(c, stdin);}

using namespace std;

int N;
vector<int> even, odd;

int main()
{
assert_digit();
scanf("%d", &N);
assert(getchar()=='n');
assert(1<=N && N<=1000);
int a;
for(int i=0; i<N; i++)
{
assert_digit();
scanf("%d", &a);
if(i!=N-1)
assert(getchar()==' ');
assert(1<=a && a<=1000);
if(a%2==0)
even.push_back(a);
else
odd.push_back(a);
}
assert(getchar()==EOF);
sort(even.begin(), even.end());
sort(odd.begin(), odd.end());
for(auto& it: even)
printf("%d ", it);
printf("%d ", accumulate(even.begin(), even.end(), 0));
for(auto& it: odd)
printf("%d ", it);
printf("%dn", accumulate(odd.begin(), odd.end(), 0));
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