Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 325 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define pb push_back
  3. #define mp make_pair
  4. #define ff first
  5. #define ss second
  6. #define debug(args...) //fprintf(stderr, args)
  7.  
  8. using namespace std;
  9.  
  10. typedef long long lint;
  11. typedef pair<int, int> pii;
  12.  
  13. const int MAXN = 1123;
  14.  
  15. vector<pii> s;
  16. vector< pair<int, pii> > w;
  17. int up[MAXN], down[MAXN];
  18.  
  19. struct eve {
  20.     int si, wi, t;
  21.     bool operator < (const eve& e) const {
  22.         if(this->h() > e.h()) return true;
  23.         else if(this->h() < e.h()) return false;
  24.         else return t < e.t;
  25.     }
  26.     int h() const {
  27.         if(t) return w[wi].ss.ff - s[si].ss;
  28.         else return w[wi].ss.ss - s[si].ss;
  29.     }
  30. };
  31.  
  32. vector<eve> e;
  33.  
  34. int main() {
  35.     int n, m;
  36.     scanf("%d%d", &n, &m);
  37.     for(int i = 0; i < n; i++) {
  38.         int x, y;
  39.         scanf("%d%d", &y, &x);
  40.         s.pb({y, x});
  41.     }
  42.     for(int i = 0; i < m; i++) {
  43.         int xi, y, xf;
  44.         scanf("%d%d%d", &y, &xi, &xf);
  45.         w.pb({y, {xi, xf}});
  46.     }
  47.     for(int i = 0; i < n; i++) {
  48.         for(int j = 0; j < m; j++) {
  49.             e.pb((eve){i, j, 0});
  50.             debug("%d, %d, %d -> h = %d\n", i, j, 0, e.back().h());
  51.             e.pb((eve){i, j, 1});
  52.             debug("%d, %d, %d -> h = %d\n", i, j, 1, e.back().h());
  53.         }
  54.     }
  55.     sort(e.begin(), e.end());
  56.     int now = 0, ans = 0;
  57.     for(eve x : e) {
  58.         debug("Estrela %d\nParede %d\nTipo %d\n\n", x.si, x.wi, x.t);
  59.         debug("Estrela %d\nUP %d\nDOWN %d\n\n", x.si, up[x.si], down[x.si]);
  60.         int ok = up[x.si] && down[x.si];
  61.         if(x.t) {
  62.             if(w[x.wi].ff > s[x.si].ff) up[x.si]--;
  63.             else down[x.si]--;
  64.             if(ok && !(up[x.si] && down[x.si])) now--;
  65.         } else {
  66.             if(w[x.wi].ff > s[x.si].ff) up[x.si]++;
  67.             else down[x.si]++;
  68.             if(!ok && (up[x.si] && down[x.si])) now++;
  69.         }
  70.         debug("Estrela %d\nUP %d\nDOWN %d\n\n", x.si, up[x.si], down[x.si]);
  71.         debug("AGORA %d\n\n\n", now);
  72.         ans = max(ans, now);
  73.     }
  74.     printf("%d\n", ans);
  75.     return 0;
  76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top