fork download
  1. #include "gap.h"
  2.  
  3. long long findGap(int T, int N)
  4. {
  5. if (T==1)
  6. {
  7. long long int mn = -1, mx = 1000000000000000001;
  8. long long int answer[N];
  9. if (N % 2 == 0)
  10. {
  11. MinMax(mn, mx, &mn, &mx);
  12. answer[0] = mn;
  13. answer[N-1] = mx;
  14. for (long long int i = 0; i < (N-2)/2; i++)
  15. {
  16. MinMax(mn+1, mx-1, &mn, &mx);
  17. answer[i+1] = mn;
  18. answer[N-i-2] = mx;
  19. }
  20. }
  21. else
  22. {
  23. MinMax(mn, mx, &mn, &mx);
  24. answer[0] = mn;
  25. answer[N-1] = mx;
  26. for (long long int i = 0; i < (N-3)/2; i++)
  27. {
  28. MinMax(mn+1, mx-1, &mn, &mx);
  29. answer[i+1] = mn;
  30. answer[N-i-2] = mx;
  31. }
  32.  
  33. MinMax(mn+1, mx-1, &mn, &mx);
  34. answer[(N-1)/2] = mn;
  35.  
  36. }
  37.  
  38. long long int max = -1;
  39. for (long long int i = 0; i < N-1; i++)
  40. {
  41. if (answer[i+1]-answer[i] > max)
  42. {
  43. max = answer[i+1]-answer[i];
  44. }
  45. }
  46.  
  47. return max;
  48. }
  49. else
  50. {
  51. long long int mn = -1, mx = 1000000000000000001;
  52. MinMax(mn, mx, &mn, &mx);
  53.  
  54. long long int bottom[N-1];
  55. long long int top[N-1];
  56. bottom[0] = mn;
  57. top[N-2]=mx;
  58.  
  59. for (long long int i = 1; i < N-1; i++)
  60. {
  61. bottom[i] = mn+(mx-mn)*i/(N-1)+1;
  62. top[i-1]=bottom[i]-1;
  63. }
  64.  
  65. long long int highest = -1;
  66. long long int currbot, currtop;
  67. MinMax(bottom[0], top[0], &mn, &mx);
  68. currtop = mx;
  69. for (long long int i = 1; i < N-1; i++)
  70. {
  71. MinMax(bottom[i], top[i], &mn, &mx);
  72. if (mn == -1)
  73. {
  74.  
  75. }
  76. else
  77. {
  78. currbot=mn;
  79. if (highest < currbot - currtop)
  80. {
  81. highest = currbot - currtop;
  82. }
  83.  
  84. currtop = mx;
  85. }
  86. }
  87.  
  88. return highest;
  89. }
  90. }
  91.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:10: fatal error: 'gap.h' file not found
#include "gap.h"
         ^
1 error generated.
stdout
Standard output is empty