arifin_fuad_kashfy's blog

By arifin_fuad_kashfy, history, 9 days ago, In English

hellow,

i was solving a div 4 c so i am wondering why my code fialed can anyone give me a where it will help pls 306053812

thanks ! in advice

»
9 days ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Well the thing your doing is not optimal. You are checking if first element is bigger than second if yes then you are using the operation but the optimal thing to do is to just apply the operation whenever it gives a lesser number than the current number and also maintains that the previous value is smaller

»
9 days ago, # |
Rev. 7   Vote: I like it 0 Vote: I do not like it

k-a[i] can be larger than or equal to a[i-1] (k >= a[i] + a[i-1])

Instead, you should check for k-a[i] instead of k-a[i-1], if k-a[i] and doesn't work then just straight up cout << "NO"

Fun fact about the problem