fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. cin.tie(NULL);
  7. ios_base::sync_with_stdio(false);
  8. int test;
  9. cin>>test;
  10.  
  11. while(test--)
  12. {
  13. int count=0;
  14. int n,h,a,b,p;
  15. cin>>n>>h>>a>>b>>p;
  16. int g;
  17. g=h-a;
  18. int t[n],x[n];
  19. for(int i=0;i<n;i++)
  20. {
  21. cin>>t[i]>>x[i]; //t=type of barrier & x=height of barrier
  22. }
  23.  
  24. for(int i=0;i<n;i++)
  25. {
  26. if(t[i]==1)
  27. {
  28. if(g==x[i] || g<x[i])
  29. {
  30. count++;
  31. }
  32. }
  33. if(t[i]==2)
  34. {
  35. if(b==x[i] || b>x[i])
  36. {
  37. count++;
  38. }
  39. }
  40.  
  41. else
  42. {
  43. if(p>1)
  44. {
  45. count++;
  46. p=p-1;
  47. }
  48. }
  49. }
  50.  
  51. cout<<count<<endl;
  52.  
  53. }
  54. return 0;
  55. }
Success #stdin #stdout 0s 4424KB
stdin
3
6 5 1 2 3
2 2
2 1
1 10
2 8
2 4
1 2
1 4 2 5 1
2 6
6 5 1 2 3
2 2
2 1
1 10
2 8
2 4
1 6
stdout
5
0
6