fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int maxx=1000001;
  4. long long minn[maxx],a[maxx],n,p;
  5. const string ji="jump.inp";
  6. const string jo="jump.out";
  7. int tim;
  8. ofstream fout(jo);
  9. bool cmp(int x,int y)
  10. {
  11. return x>y;
  12. }
  13. void nhapfile()
  14. {
  15. ifstream fin(ji);
  16. fin>>n>>p;
  17. for(int i=1;i<=n;i++) fin>>a[i];
  18. tim=0;
  19. minn[0]=LLONG_MAX;
  20. for(int i=1;i<=n;i++)
  21. {
  22. minn[i]=min(minn[i-1],a[i]);
  23. cout<<minn[i]<<' ';
  24. }
  25. cout<<endl;
  26. }
  27. void xuly()
  28. {
  29. int j;
  30. for(int i=1;i<=n;i++)
  31. {
  32. int x=a[i]-p;
  33. j=lower_bound(minn+1,minn+n+1,x,cmp)-minn;
  34. //cout<<minn[i]<<' ';
  35. tim=max(tim,i-j);
  36. cout<<i<<' '<<j<<' '<<x<<endl;
  37. }
  38. }
  39. int main()
  40. {
  41. nhapfile();
  42. xuly();
  43. fout<<tim;
  44. }
  45.  
Success #stdin #stdout 0.01s 5572KB
stdin
Standard input is empty
stdout