Why this code is showing wrong answer;

#include
#include
using namespace std;
void roses(int A[], int N, int M){
int K;
int min_diff = INT_MAX;
for( int i = 0; i < N-1 ; i++){
for( int j = i + 1; j< N; j++ ){
if( A[i] + A[j] == M ){
K = A[j] - A[i];
if( K < 0){
K = -K;
}
min_diff = min(min_diff, K);
}
}
//cout << min_diff << endl;
}
for( int i = 0; i < N-1 ; i++){
for( int j = i + 1; j< N; j++ ){
if( A[j]>A[i]){
if( A[j] + A[i]==M && A[j]- A[i] == min_diff){
cout << "Deepak should buy roses whose prices are " << A[i] << " and " << A[j] << “.” <<endl;
}

		}
		else if( A[j] + A[i]==M && A[i]- A[j] == min_diff){
				cout << "Deepak should buy roses whose prices are " << A[j] << " and " << A[i] << "." <<endl;	
			}	
	}
}

}
int main() {
int t;
cin >> t;
for( int i = 1; i <=t ; i++){
int n;
cin >> n;
int a[n];
for ( int i = 0; i < n; i++){
cin >> a[i];
}
int m;
cin >> m;
cin.ignore();
//cout << endl;
roses( a, n, m);
}
return 0;
}

hi @akki56756_bab14f919dbad123
refer this -->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.