# Distinct Pairs (DPAIRS)

#include
#include
#include
#include
using namespace std;

int main(){
int n,m;
cin>>n>>m;
vector<pair<int,int>>vec1(n),vec2(m);

``````for(int i=0;i<n;i++){
cin>>vec1[i].first;
vec1[i].second=i;
}

for(int i=0;i<m;i++){
cin>>vec2[i].first;
vec2[i].second=i;
}

sort(vec1.begin(),vec1.end());
sort(vec2.begin(),vec2.end());

for(int i=0;i<m;i++){
cout<<vec1[0].second<<" "<<vec2[i].second<<"\n";
}

for(int i=0;i<m;i++){
cout<<vec1[n-1].second<<" "<<vec2[i].second<<"\n";
}
return 0;
``````

}

you should change the last loop to

for(int i=1;i<n;i++)
count<<vec1[i].second<<" β<<vec2[m-1].second<<β\n";

and here is a test case where your code fails
3 2
1 2 3
1 3

1 Like

**my approach is diffrent **
I want to choose an element in the starting of the list
and after that in the end of the list

how can that be correct?
both loops in your code is running from 0 to m-1. so you are printing 2m elements. the answer asks n+m-1 sums.

Ok ok ok thanks broβ¦
I now understand