Untitled
unknown
c_cpp
2 years ago
555 B
9
Indexable
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, n;
cin >> k >> n;
int a[n], b[n];
for(int i = 0; i < n; i++) {
cin >> a[i];
}
for(int i = 0; i < n; i++) {
cin >> b[i];
}
sort(a, a + n);
sort(b, b + n);
long long res = 0;
for(int i = 0; i < n; i++) {
if(a[i] >= k) {
res += n;
}
else {
int idx = lower_bound(b, b + n, k - a[i]) - b;
res += n - idx;
}
}
cout << res << endl;
return 0;
}
Editor is loading...
Leave a Comment