Dpairs problem of contest 3

Can anyone tell what is wrong in this approach for Dpairs. It’s giving WA on some test cases
Here is my code…https://www.codechef.com/viewsolution/33132143

Your logic is right, but you’re printing the output incorrectly. Think about why.

1 Like

yup i got it…thnx

I am failing two test cases and i am not able to figure them out, can anyone help me
Failing task# 6 and 11
Here is my code

#include <bits/stdc++.h>
using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n = 0, m = 0;
cin >> n >> m;
int a[n], b[m];
int max = 0, max_pos = 0, min = 0, min_pos = 0;
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] >= max){
max = a[i];
max_pos = i;
}
}
cin >> b[0];
min = b[0];
min_pos = 0;
for(int i = 1; i < m; i++){
cin >> b[i];
if(b[i] <= min){
min = b[i];
min_pos = i;
}
}
for(int i = 0; i < m; i++)
cout << max_pos << " " << i << “\n”;

for(int i = 0; i < n; i++)
if(i != max_pos)
cout << i << " " << min_pos << “\n”;
return 0;
}