Блог пользователя arifin_fuad_kashfy

Автор arifin_fuad_kashfy, история, 10 дней назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
9 дней назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

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 дней назад, # |
Rev. 7   Проголосовать: нравится 0 Проголосовать: не нравится

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