Advertisement
erfanul007

LightOJ 1016

Jul 3rd, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. typedef long long int ll;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scii(n,m) scanf("%d %d",&n,&m)
  17. #define scl(n) scanf("%lld",&n)
  18. #define scd(n) scanf("%lf",&n)
  19. #define scs(s) scanf("%s",s)
  20. #define pfi(n) printf("%d",n)
  21. #define pfl(n) printf("%lld",n)
  22. #define pff(n) cout<<n
  23. #define line printf("\n")
  24. #define spc printf(" ")
  25. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  26. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  27. #define cspf(i) printf("Case %d: ", i)
  28. #define pb push_back
  29. #define mp make_pair
  30. #define ff first
  31. #define ss second
  32. #define all(v) v.begin(),v.end()
  33. #define rall(v) v.rbegin(),v.rend()
  34. #define read() freopen("input.txt", "r", stdin)
  35. #define write() freopen("output.txt", "w", stdout)
  36. /// Constants
  37. #define eps 1e-9
  38. #define PI acos(-1.0) // 3.1415926535897932
  39. #define MAX 1000009*/
  40.  
  41. void fastIO()
  42. {
  43. ios_base::sync_with_stdio(false);
  44. cin.tie(NULL);
  45. }
  46.  
  47. int main()
  48. {
  49. //read();
  50. //write();
  51. int t;
  52. sci(t);
  53. loop(i,1,t){
  54. int n,w;
  55. scii(n,w);
  56. cspf(i);
  57. vi v;
  58. loop(j,1,n){
  59. int x,y;
  60. scii(x,y);
  61. v.pb(y);
  62. }
  63. sort(all(v));
  64. int cnt=0;
  65. loop(j,0,n-1){
  66. cnt++;
  67. int x = v[j]+w;
  68. while(j<n-1 && v[j+1]<=x) j++;
  69. }
  70. pfi(cnt);line;
  71. }
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement