Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <set>
- #include <vector>
- #include <algorithm>
- int main()
- {
- int n = 0;
- std::scanf("%d", &n);
- std::multiset<int> first;
- for (int i = 0; i < n; i++)
- {
- int x = 0;
- std::scanf("%d", &x);
- first.insert(x);
- }
- int m = 0;
- std::scanf("%d", &m);
- std::multiset<int> second;
- for (int i = 0; i < m; i++)
- {
- int x = 0;
- std::scanf("%d", &x);
- second.insert(x);
- }
- if (*second.rbegin() != *first.rbegin())
- std::puts("NO");
- else
- {
- std::vector<int> ans;
- std::set_union(first.begin(), first.end(), second.begin(), second.end(), std::back_inserter(ans));
- std::printf("%llu", ans.size());
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment