so i was wondering why my code somehow gives the correct output only when i remove the 2 sort functions as the value themselves don't change?
Also, I'm unable to post on code forces yet as I'm a beginner so i thought i could get help here. Thanks so much in advance!
My code:
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n, m, k, count = 0;
cin >> n >> m >> k;
int A[1000], B[1000];
for (int i = 0; i < n; i++){
cin >> A[i];
}
for(int i = 0; i < m; i++){
cin >> B[i];
}
sort(begin(A), end(A));
sort(begin(B), end(B));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(A[i] + B[j] <= k){
count++;
}
}
}
cout << count << endl;
}
}
Can't figure out why it will only work when i remove sort function