Advertisement
BaoJIaoPisu

Untitled

Oct 10th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pb push_back
  5. #define pf push_front
  6. #define popb pop_back
  7. #define popf pop_front
  8. #define ins insert
  9. #define pq priority_queue
  10. #define minele min_element
  11. #define maxele max_element
  12. #define lb lower_bound //first pos >= val
  13. #define ub upper_bound // first pos > val
  14. #define cnt_bit __builtin_popcount
  15. #define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  16. //#pragma GCC optimize("Ofast")
  17. //#pragma GCC target("avx,avx2,fma")
  18. using namespace std;
  19.  
  20. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  21.  
  22. typedef long long ll;
  23. typedef pair<ll, ll> pll;
  24. typedef pair<int, int> pii;
  25.  
  26.  
  27. int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1};
  28. int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  29. int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  30.  
  31. const ll oo = 1e18;
  32. const ll maxN = 1e6;
  33.  
  34. /* Author : Le Ngoc Bao Anh, 10A5, LQD High School for Gifted Student */
  35.  
  36. void maximize(int &a, int b) {
  37.     a = max(a, b);
  38. }
  39.  
  40. void minimize(int &a, int b) {
  41.     a = min(a, b);
  42. }
  43.  
  44. const int N = 2e5 + 100;
  45. pii a[N], b[N], rb[N];
  46.  
  47. void solve() {
  48.     int n, m, q; cin >> n >> m >> q;
  49.     for(int i = 1; i <= n; i++) cin >> a[i].fi;
  50.     for(int i = 1; i <= n; i++) cin >> a[i].se;
  51.     for(int i = 1; i <= m; i++) cin >> b[i].fi;
  52.     for(int i = 1; i <= m; i++) cin >> b[i].se;
  53.     for(int i = 1; i <= m; i++) rb[i] = b[i];
  54.  
  55.     sort(a + 1, a + 1 + n);
  56.     while(q--) {
  57.         multiset<int> s;
  58.         int pos; cin >> pos;
  59.         sort(b + pos, b + pos + n);
  60.         int iter = pos;
  61.         int ans = 0;
  62.         for(int i = 1; i <= n; i++) {
  63.             while(b[iter].fi < a[i].fi && iter <= pos + n - 1) {
  64.                 s.ins(b[iter].se);
  65.                 iter++;
  66.             }
  67.  
  68.             if(s.empty()) continue;
  69.             auto it = s.ub(a[i].se);
  70.             while(it != s.begin()) {
  71.                 it--;
  72.                 if((*it) < a[i].se) break;
  73.             }
  74.             if((*it) < a[i].se) ans++, s.erase(it);
  75.         }
  76.  
  77.         for(int i = pos; i <= pos + n - 1; i++) b[i] = rb[i];
  78.         cout << ans << '\n';
  79.     }
  80. }
  81.  
  82. int main()
  83. {
  84.     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  85.     #ifndef ONLINE_JUDGE
  86.     freopen("input.txt", "r", stdin);
  87.     freopen("output.txt", "w", stdout);
  88.     #else
  89.     //online
  90.     #endif
  91.  
  92.     int tc = 1, ddd = 0;
  93.     // cin >> tc;
  94.     while(tc--) {
  95.         //ddd++;
  96.         //cout << "Case #" << ddd << ": ";
  97.         solve();
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement