Please help me with the below problem

Pair Sort Version 3

Below is my code and it is giving errors for some test cases. Please help me out.

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

const bool sortBySecondDesc(const pair<long long int,long long int> &a,const pair<long long int,long long int> &b){
return(a.second > b.second);
}

int main(){
long long int N,inp;
cin>>N;
vector< pair<long long int,long long int> > p;
vector v1;
vector v2;
for(long long int i=0;i<N;i++){
cin>>inp;
v1.push_back(inp);
}
for(long long int i=0;i<N;i++){
cin>>inp;
v2.push_back(inp);
}
for(long long int j=0;j<N;j++){
p.push_back(make_pair(v1[j],v2[j]));
}
sort(p.begin(),p.end(),sortBySecondDesc);
for(auto i:p){
cout<<i.first<<" “<<i.second<<” ";
}
return 0;
}

You can check its solution here

Please format your code - the forum software has mangled it and it won’t compile! :slight_smile:

Edit:

Meh - I guess I can guess what your code is supposed to look like. Consider the test input:

3
3 2 1
2 2 2