paranid5

City line

Sep 21st, 2020 (edited)
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <cstdio>
  2. #include <set>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. int main()
  7. {
  8.     int n = 0;
  9.     std::scanf("%d", &n);
  10.     std::multiset<int> first;
  11.  
  12.     for (int i = 0; i < n; i++)
  13.     {
  14.         int x = 0;
  15.         std::scanf("%d", &x);
  16.         first.insert(x);
  17.     }
  18.  
  19.     int m = 0;
  20.     std::scanf("%d", &m);
  21.     std::multiset<int> second;
  22.  
  23.     for (int i = 0; i < m; i++)
  24.     {
  25.         int x = 0;
  26.         std::scanf("%d", &x);
  27.         second.insert(x);
  28.     }
  29.  
  30.     if (*second.rbegin() != *first.rbegin())
  31.         std::puts("NO");
  32.  
  33.     else
  34.     {
  35.         std::vector<int> ans;
  36.         std::set_union(first.begin(), first.end(), second.begin(), second.end(), std::back_inserter(ans));
  37.         std::printf("%llu", ans.size());
  38.     }
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment