Advertisement
Guest User

Untitled

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