Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "pch.h"
- #include <iostream>
- #include <vector>
- #include <iomanip>
- using namespace std;
- #define ll long long
- double sqr(double x) {
- return (x * x);
- }
- ostream & operator << (ostream & out, vector<ll> & v) {
- for (int i = 0; i < v.size(); i++) {
- out << v[i] << ' ';
- }
- return out;
- }
- int step(ll x, int n) {
- int y = x;
- x = 1;
- for (int i = 0; i < n; i++) {
- x *= y;
- }
- return x;
- }
- void LlVec(vector<ll> &a) {
- int x = 0;
- int h = 1;
- vector<char> fc;
- char c = getchar();
- if (c != '\n' & c != -1) {
- if (c == '-') {
- h = -1;
- c = getchar();
- }
- while (c != ' ' & c != '\n' & c != -1) {
- fc.push_back(c);
- c = getchar();
- }
- int k = fc.size();
- for (int i = k - 1; i >= 0; i--) {
- x += (fc[i] - 48) * step(10, k - i - 1);
- }
- x *= h;
- a.push_back(x);
- do {
- cin >> x;
- a.push_back(x);
- c = getchar();
- } while (c != -1 & c != '\n');
- }
- }
- int main()
- {
- vector<ll> m;
- vector<ll> table(4, 0);
- LlVec(m);
- int x;
- x = 0;
- bool xx, yy, aa, bb;
- xx = false;
- yy = false;
- aa = false;
- bb = false;
- for (int i = 0; i < m.size(); i++) {
- x = m[i];
- if (x > table[3] | !xx) {
- if (xx) {
- yy = true;
- table[2] = table[3];
- }
- xx = true;
- table[3] = x;
- }
- else if (x > table[2] | !yy) {
- yy = true;
- if (table[2] < table[0] | !aa) {
- if (aa) {
- bb = true;
- table[1] = table[0];
- }
- aa = true;
- table[0] = table[2];
- }
- else if (table[2] < table[1] | !bb) {
- bb = true;
- table[1] = table[2];
- }
- table[2] = x;
- }
- else if (x < table[0] | !aa) {
- if (aa) {
- bb = true;
- table[1] = table[0];
- }
- aa = true;
- table[0] = x;
- }
- else if (x < table[1] | !bb) {
- bb = true;
- table[1] = x;
- }
- }
- if (table[0] * table[1] > table[2] * table[3]) {
- cout << table[0] << " " << table[1];
- }
- else {
- cout << table[2] << " " << table[3];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement