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 Charged Up Array problem solution

YASH PAL, 31 July 202414 February 2026
In this HackerEarth Charged Up Array problem solution, You are given an array A of size N. An element Ai is said to be charged if its value(Ai) is greater than or equal to Ki. Ki is the total number of subsets of array A, that consist of element Ai.
The total charge value of the array is defined as the summation of all charged elements present in the array mod (10 to power 9 plus 7). Your task is to output the total charge value of the given array A.
HackerEarth Charged Up Array problem solution

HackerEarth Charged Up Array problem solution.

#include <bits/stdc++.h>
#define M 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T;
    cin>>T;
    while(T--)
    {
        int N;
        cin>>N;
        long long arr[N];
        for(int i=0;i<N;i++)
            cin>>arr[i];
        if(N>=64)
            cout<<0<<endl;
        else
        {
            long long val=(1ll<<(N-1));
            long long ans=0;
            for(int i=0;i<N;i++)
                if(arr[i]>=val)
                    ans=(ans+arr[i]%M)%M;
            cout<<ans<<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