fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=3e4;
  5. const int MaxY=3e4;
  6. const int MaxP=1e5;
  7.  
  8. int N,Y,A,B;
  9. int add[130002];
  10. int main() {
  11. while(cin>>N>>Y){
  12. for(int p=0; p<=MaxP+Y+1;p++)
  13. add[p]=0;
  14. for(int n=0;n<N;n++){
  15. cin>>A>>B;
  16. if(B-A>Y)//無論夾子在哪都夾不起來
  17. continue;
  18. add[B]+=1;
  19. add[A+1+Y]-=1;
  20. }
  21. int now=0;
  22. for(int p=0;p<=Y;p++)
  23. now+=add[p];
  24. int ansC=0;
  25. int ansN=now;
  26. for(int p=Y+1;p<=MaxP+1+Y;p++){
  27. now+=add[p];
  28. if(now>ansN){
  29. ansN=now;
  30. ansC=1;
  31. }else if(ansN==now){
  32. ansC+=1;
  33. }
  34. }
  35. cout<<ansC<<" "<<ansN<<endl;
  36. }
  37. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty