Hi, I’m Solving this problem in code forces.
http://codeforces.com/contest/287/problem/B
And my idea is that if n is lesser than k we should print 1.
else we should declare an array of sums size of k that sum[k] = sum[k-1] - i(i is the for var that it’s increasing from 0 to k).
and then we perform a binary search on that and with value n and if it’s not we print -1 if it’s we print the index of sum arr.
but the k can be up to 10^9 so the time complexity to declare that sum array if the k be 10^9 will be huge and it will get tle!
How I can make it better or I must change my idea?