Read the problem statement clarification at the top of the discussion post. You are misinterpreting the question, observe the table given carefully.

Active In

Competitive Programming

Web Development

Music

Game of Thrones

International Olympiad in Informatics

Machine Learning

TED Talks

Stand-up Comedy

Artificial Intelligence

Technology

Featured Contributions

reply in this discussion

Read the problem statement clarification at the top of the discussion post. You are misinterpreting the question, observe the table given carefully.

Read more… (22 words)

reply in this discussion

reply in this discussion

Yes I did think of a way without actually sorting. I coded it and submitted the solution, but for some reason I'm getting a few test cases wrong. Could you have a look at it?

Thanks!

#include <bits/stdc++.h>using namespace std;bool pyramid(int m, int* count){int blocks = 0;for(int i = 1000000; i > m; i--)blocks += count[i];//counting number of blocks with side > mfor(int i = m; i > 0; i--){if(count[i] == 0)blocks--;//if for any side i(<m) the block is not present, we use one of the previous unused blockselseblocks += (count[i] - 1);//else we add the extra blocksif(blocks < 0)return false;//if we ever run out of blocks, return false

Read more… (36 words)

reply in this discussion

The problem can be solved simply using sorting, but I think using binary search to solve it would be much more fun and informative. What do you all think?

Read more… (29 words)