Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int A[50004], B[50004];
- int main(){
- int Q;
- scanf("%d", &Q);
- while(Q--)
- {
- int N;
- scanf("%d", &N);
- for(int i=1; i<=N; i++)
- scanf("%d", &A[i]);
- sort(A+1, A+1+N);
- memset(B, 0, sizeof(B));
- int v;
- scanf("%d", &v);
- while(v--)
- {
- int L, R;
- scanf("%d %d", &L, &R);
- L = lower_bound(A+1, A+1+N, L) - A;
- R = upper_bound(A+1, A+1+N, R) - A;
- B[L]++, B[R]--;
- }
- int ans = 0;
- for(int i=1; i<=N; i++)
- {
- B[i] += B[i-1];
- ans += (B[i]>0);
- }
- printf("%d\n", ans);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment