Help with error

prob: https://hack.codingblocks.com/app/contests/2022/591/problem

code: https://ide.codingblocks.com/s/425516

getting seg fault

you can not use [] operator on a vector before initializing the vector

this will give errror

for(int i = 0 ; i < n; i ++) {

            cin>>denoms[i];

        }

define vector like this
vector denoms(100000);
after that it will not give error