Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. //#include "pch.h"
  2. #include <iostream>
  3. #include <vector>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. #define ll long long
  8.  
  9. double sqr(double x) {
  10. return (x * x);
  11. }
  12.  
  13. ostream & operator << (ostream & out, vector<ll> & v) {
  14. for (int i = 0; i < v.size(); i++) {
  15. out << v[i] << ' ';
  16. }
  17. return out;
  18. }
  19.  
  20.  
  21. int step(ll x, int n) {
  22. int y = x;
  23. x = 1;
  24. for (int i = 0; i < n; i++) {
  25. x *= y;
  26. }
  27. return x;
  28. }
  29.  
  30. void LlVec(vector<ll> &a) {
  31. int x = 0;
  32. int h = 1;
  33. vector<char> fc;
  34. char c = getchar();
  35. if (c != '\n' & c != -1) {
  36. if (c == '-') {
  37. h = -1;
  38. c = getchar();
  39. }
  40. while (c != ' ' & c != '\n' & c != -1) {
  41. fc.push_back(c);
  42. c = getchar();
  43. }
  44. int k = fc.size();
  45. for (int i = k - 1; i >= 0; i--) {
  46. x += (fc[i] - 48) * step(10, k - i - 1);
  47. }
  48. x *= h;
  49. a.push_back(x);
  50. do {
  51. cin >> x;
  52. a.push_back(x);
  53. c = getchar();
  54. } while (c != -1 & c != '\n');
  55. }
  56. }
  57.  
  58. int main()
  59. {
  60. vector<ll> m;
  61. vector<ll> table(4, 0);
  62. LlVec(m);
  63. int x;
  64. x = 0;
  65. bool xx, yy, aa, bb;
  66. xx = false;
  67. yy = false;
  68. aa = false;
  69. bb = false;
  70. for (int i = 0; i < m.size(); i++) {
  71. x = m[i];
  72. if (x > table[3] | !xx) {
  73. if (xx) {
  74. yy = true;
  75. table[2] = table[3];
  76. }
  77. xx = true;
  78. table[3] = x;
  79. }
  80. else if (x > table[2] | !yy) {
  81. yy = true;
  82. if (table[2] < table[0] | !aa) {
  83. if (aa) {
  84. bb = true;
  85. table[1] = table[0];
  86. }
  87. aa = true;
  88. table[0] = table[2];
  89. }
  90. else if (table[2] < table[1] | !bb) {
  91. bb = true;
  92. table[1] = table[2];
  93. }
  94. table[2] = x;
  95. }
  96. else if (x < table[0] | !aa) {
  97. if (aa) {
  98. bb = true;
  99. table[1] = table[0];
  100. }
  101. aa = true;
  102. table[0] = x;
  103. }
  104. else if (x < table[1] | !bb) {
  105. bb = true;
  106. table[1] = x;
  107. }
  108. }
  109. if (table[0] * table[1] > table[2] * table[3]) {
  110. cout << table[0] << " " << table[1];
  111. }
  112. else {
  113. cout << table[2] << " " << table[3];
  114. }
  115. return 0;
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement