Advertisement
YEZAELP

o56_oct_c1_tiger

Jan 21st, 2022
660
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int inf = 1e9;
  5. const int N = 1e3 + 10;
  6. const int M = 1e3 + 10;
  7. using pi = pair <int, int>;
  8. pi fire[N], tiger[M];
  9. unordered_map <int, int> cnt;
  10.  
  11. int dist(pi a, pi b){
  12.     return abs(a.first - b.first) + abs(a.second - b.second);
  13. }
  14.  
  15. int main(){
  16.  
  17.     int n, m;
  18.     scanf("%d %d", &n, &m);
  19.  
  20.     for(int i = 1; i <= n; i ++)
  21.         scanf("%d %d", &fire[i].first, &fire[i].second);
  22.  
  23.     for(int i = 1; i <= m; i ++)
  24.         scanf("%d %d", &tiger[i].first, &tiger[i].second);
  25.  
  26.     for(int i = 1; i <= m; i ++){
  27.         int mn = inf;
  28.         for(int j = 1; j <= n; j ++){
  29.             mn = min(mn, dist(fire[j], tiger[i]));
  30.         }
  31.         cnt[mn] ++;
  32.     }
  33.  
  34.     int mx = 0;
  35.     for(auto i: cnt)
  36.         mx = max(mx, i.second);
  37.  
  38.     printf("%d", mx);
  39.  
  40.     return 0;
  41. }
Advertisement
RAW Paste Data Copied
Advertisement