Codeforces Blitz Cup 2025 Final Rounds Have Started! Join the stream now: https://youtu.be/rbHFLNg7Nkc. ×

arifin_fuad_kashfy's blog

By arifin_fuad_kashfy, history, 3 weeks 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

»
3 weeks 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

»
3 weeks 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