fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define MAX 50010
  4.  
  5. typedef long long int ll;
  6.  
  7. struct info {
  8. ll x;
  9. ll flag;
  10. }arr[100100];
  11.  
  12. bool cmp(struct info a, struct info b) {
  13. if(a.x < b.x) return true;
  14. if(a.x == b.x) {
  15. if(a.flag < b.flag) return true;
  16. else return false;
  17. }
  18. return false;
  19. }
  20.  
  21. int main(void){
  22. ll T,t,n;
  23. scanf("%lld",&T);
  24. for(t = 1; t <= T; t++){
  25. scanf("%lld",&n);
  26. ll x,y;
  27. ll guno = 0;
  28. for(ll i = 1; i <= n; i++){
  29. scanf("%lld %lld",&x,&y);
  30. guno++;
  31. arr[guno].x = x;
  32. arr[guno].flag = 1;
  33. guno++;
  34. arr[guno].x = y;
  35. arr[guno].flag = 2;
  36. }
  37. sort(arr+1,arr+1+guno,cmp);
  38. ll counter = 1;
  39. ll f = 0;
  40. for(ll i = 2; i <= guno; i++){
  41. if(arr[i].flag == 2) {
  42. f++;
  43. }
  44. else if(arr[i].flag == 1) {
  45. if(f == 0) {
  46. counter++;
  47. }
  48. else if(f != 0) {
  49. f--;
  50. }
  51. }
  52. }
  53.  
  54. printf("Case %lld: %lld\n",t,counter);
  55. }
  56. return 0;
  57. }
  58.  
  59.  
Runtime error #stdin #stdout 0.01s 5036KB
stdin
Standard input is empty
stdout
Standard output is empty