In this

**HackerEarth Filling stones problem solution**You are given an integer N. You have total 2N stones numbered from 1 to 2N. You have initially two empty arrays of size N each. You have to fill both the arrays utilizing all the 2N stones and using each stone in only one array.Let us define the beauty of an array as the difference between the sum of elements at odd positions and the sum of elements at even positions.

The beauty of an array is |s1 - s2| where:

S1 = Sigma(Ai1) where Ai1 are the elements positioned at an odd position in an array

S2 = Sigma(Ai2) where Ai2 are the elements positioned at an even position in an array

Your task is to arrange the stones in both arrays such that the product of the beauty of both arrays is as minimum as possible.

## HackerEarth Filling stones problem solution.

`#include<bits/stdc++.h>`

#include<climits>

using namespace std;

int main() {

cin.tie(0);

long long int n;

cin >> n;

long long int ans = 0;

if (n == 1) {

ans = 2;

}

else if (n == 2) {

ans = 1;

}

cout << ans << endl;

}

## 0 Comments