Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. void main(void) {
  8.  
  9. ifstream fin("react.in");
  10. ofstream fout("react.out");
  11.  
  12. long long maxvaluex = 0, maxvaluey = 0, numberoflines = 0;
  13. int counter = 1, counter2 = 0, maxv = 0, peresech = 0;
  14.  
  15. vector <long long> vec1;
  16. vector <long long> vec2;
  17.  
  18. fin >> maxvaluex >> maxvaluey >> numberoflines;
  19.  
  20. int* bottomleftx = new int[numberoflines];
  21. int* bottomlefty = new int[numberoflines];
  22. int* bottomrightx = new int[numberoflines];
  23. int* bottomrighty = new int[numberoflines];
  24.  
  25. for (int i = 0; i < numberoflines; i++) {
  26. fin >> bottomleftx[i] >> bottomlefty[i] >> bottomrightx[i] >> bottomrighty[i];
  27. }
  28.  
  29. for (int i = 0; i < numberoflines; i++) {
  30. if ((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) > maxvaluex) {
  31. if (((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex) != long long(((maxvaluey * bottomleftx[i]) / bottomrighty[i]))) {
  32. vec1.push_back((((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex) + 1);
  33. }
  34. else {
  35. vec1.push_back(((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + maxvaluex);
  36. }
  37. }
  38. else {
  39. if ((long double)((maxvaluey * bottomleftx[i]) / bottomrighty[i]) != long long(((maxvaluey * bottomleftx[i]) / bottomrighty[i]))) {
  40. vec1.push_back(((maxvaluey * bottomleftx[i]) / bottomrighty[i]) + 1);
  41. }
  42. else {
  43. vec1.push_back((maxvaluey * bottomleftx[i]) / bottomrighty[i]);
  44. }
  45. }
  46. }
  47.  
  48. for (int i = 0; i < numberoflines; i++)
  49. {
  50. if ((long double)((maxvaluey * bottomrightx[i]) / bottomlefty[i]) > maxvaluex) {
  51. vec2.push_back(maxvaluey - (maxvaluex * bottomlefty[i] / bottomrightx[i]) + maxvaluex);
  52. }
  53. else {
  54. vec2.push_back(((maxvaluey * bottomrightx[i]) / bottomlefty[i]));
  55. }
  56. }
  57.  
  58. sort(vec1.begin(), vec1.end());
  59. sort(vec2.begin(), vec2.end());
  60. /*int tempforsortvec1 = 0;
  61. for (int i = 0; i < vec1.size() - 1; i++) {
  62. for (int j = 0; j < vec1.size() - i - 1; j++) {
  63. if (vec1[j] > vec1[j + 1]) {
  64. tempforsortvec1 = vec1[j];
  65. vec1[j] = vec1[j + 1];
  66. vec1[j + 1] = tempforsortvec1;
  67. }
  68. }
  69. }
  70.  
  71. int tempforsortvec2 = 0;
  72. for (int i = 0; i < vec2.size() - 1; i++) {
  73. for (int j = 0; j < vec2.size() - i - 1; j++) {
  74. if (vec2[j] > vec2[j + 1]) {
  75. tempforsortvec2 = vec2[j];
  76. vec2[j] = vec2[j + 1];
  77. vec2[j + 1] = tempforsortvec2;
  78. }
  79. }
  80. }*/
  81.  
  82. for (int i = 1; i < numberoflines; i++)
  83. {
  84. if (vec1[i] <= vec2[counter2])
  85. {
  86. counter++;
  87.  
  88. if (counter > maxv)
  89. {
  90. maxv = counter;
  91. peresech = vec1[i];
  92. }
  93. }
  94. else
  95. {
  96. counter--;
  97. counter2++;
  98. i--;
  99. }
  100. }
  101.  
  102. if (peresech > maxvaluex)
  103. {
  104. fout << maxv << " " << maxvaluex << " " << -(peresech - maxvaluex - maxvaluey);
  105. }
  106. else
  107. {
  108. fout << maxv << " " << peresech << " " << maxvaluey;
  109. }
  110.  
  111. delete[] bottomleftx;
  112. delete[] bottomlefty;
  113. delete[] bottomrightx;
  114. delete[] bottomrighty;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement