Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- int k, n;
- cin >> k >> n;
- vector<int> a(n), b(n);
- for(int &x : a) {
- cin >> x;
- }
- for(int &x : b) {
- cin >> x;
- }
- sort(a.begin(), a.end());
- sort(b.begin(), b.end());
- long long ret = 0;
- for(int i = 0; i < n; i++) {
- int left = k - a[i];
- if(left < 0) continue;
- int cnt = (int)(upper_bound(b.begin(), b.end(), left - 1) - b.begin());
- if(cnt >= 0 and cnt <= n) {
- ret += cnt;
- }
- }
- long long all = (long long)(n) * (long long)(n);
- cout << all - ret << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement