Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <map>
- using namespace std;
- typedef long long ll;
- 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 answer = 0;
- for(int i = 0; i < n; i++) {
- int fali = k - a[i];
- int indeks = lower_bound(b, b + n, fali) - b;
- if(indeks >= 0 and indeks < n) {
- answer += (n - indeks);
- }
- }
- cout << answer << endl;
- return 0;
- }
- /*
- 4 5
- 7 5 3 4 2
- 4 3 2 2 1
- k = 4
- 2, 3, 4, 5, 7
- 1, 2, 2, 3, 4
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement