Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main() {
- int k, n;
- cin >> k >> n;
- vector<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.begin(), a.end());
- sort(b.begin(), b.end());
- long long result = 0;
- for(int i = 0; i < n; i++) {
- int x = k - a[i];
- int idx = lower_bound(b.begin(), b.end(), x) - b.begin();
- if(idx >= 0 and idx < n) {
- result += n - idx;
- }
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement