Failed In Test case Pair of Roses

CodeLink->https://ide.codingblocks.com/s/243247
try a different approach but not able to submit.

hello @imsaurabh


u should store values in map but actually u r storing index in res and map.
modify it .
also while printing res, print smaller one before bigger one

hello @aman212yadav while printing the res i am printing the res.ff and res.ss. So, how can i solve this

it is simple.
cout<<min(a,b) <<" "<<max(a,b);

@aman212yadav what is a and b

@imsaurabh
a=res.ff
b=res.ss

@aman212yadav res contains the index of value which have less difference in i&j ,So if i write
cout<<a[min(res.ff, res.ss)];
cout<< a[max(res.ff, res.ss)]
it shows wrong answer

image
use a[res.ff] and a[res.ss] here as well.

also newdiff will be
a[i]-a[m[target]

@aman212yadav i am still not getting answer So, can you changes the error in my code and share the update code link with me.

check ur updated code here->

@aman212yadav Thanx Bro, but i am not able to submit the code on codingblocks beacuse of the website not working right now, while it working then i revert you back the status of my code.
So, can you please tell me, in which test case my code was not run perfectly.

it is working ,
try in incognito

.

u were not calculating old and newdiff correctly,that was the only logical error in ur code.

@aman212yadav thank you bro