fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main() {
  7. // your code goes here
  8. int t, n, arr[105], dep[105], hr, count, max;
  9. scanf("%d", &t);
  10. while(t--) {
  11. scanf("%d", &n); hr=0; count=0; max=0;
  12. for(int i=0; i<n; i++) scanf("%d", &arr[i]);
  13. for(int i=0; i<n; i++) scanf("%d", &dep[i]);
  14. while(hr<1005) {
  15. for(int i=0; i<n; i++) {
  16. if(hr==arr[i]) count++; if(count>max) max=count;
  17. if(hr==dep[i]) count--;
  18. } hr++;
  19. }
  20. printf("%d\n", max);
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 3344KB
stdin
4
3
1 2 3
4 5 6
5
1 2 3 4 5
2 3 4 5 6
7
13 6 5 8 2 10 12
19 18 6 9 9 11 15
5
1 4 1 3 5 
9 4 12 8 10
stdout
3
1
3
4