My issue
What wrong in my code?
My code
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main() {
int T;
cin>>T;
for(int i = 1; i <= T; i++) {
long long int N,M;
cin>>N>>M;
long long int A[N],B[M];
for(int j=0;j<N;j++) {
cin>>A[j];
}
for(int j=0;j<M;j++) {
cin>>B[j];
}
sort(A,A+N,greater<int>());
sort(B,B+M,greater<int>());
long long int count = 0;
if(N >= 4 && M >= 4 && N+M >= 11) {
for(int j=0;j<4;j++) {
count += (A[j]+B[j]);
}
vector<long long int>V(11);
for(int j=4;j<N;j++) {
V.push_back(A[j]);
}
for(int j=4;j<M;j++) {
V.push_back(B[j]);
}
sort(V.begin(),V.end(),greater<long long int>());
int bount = 0;
for(int j = 0;j<3;j++) {
bount += V[j];
}
cout<<count+bount<<endl;
}
else {
cout<<"-1"<<endl;
}
}
return 0;
}
Problem Link: GAME 11 Practice Coding Problem