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;
- 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 x = k - a[i];
- int idx = lower_bound(b, b + n, x) - b;
- if(idx >= 0 and idx < n) {
- res += n - idx;
- }
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement