Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning (disable : 4996)
- #pragma comment(linker, "/STACK:36777216")
- #include <stdlib.h>
- #include <iostream>
- #include <vector>
- #include <string>
- #include <assert.h>
- #include <stack>
- #include <algorithm>
- #include <ios>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <queue>
- #include <set>
- #include <functional>
- #include <cmath>
- #include <sstream>
- #include <map>
- #include <memory.h>
- #include <stdio.h>
- #include <cassert>
- #include <string.h>
- #include <deque>
- #include <ctime>
- #include <unordered_map>
- #include <list>
- #define forn(i , n) for (i64 i = 0; i < n; ++i)
- #define down(i, n) for (int i = (n) - 1; i >= 0; --i)
- using namespace std;
- typedef unsigned long long int u64;
- typedef long long int i64;
- typedef vector<int> vint;
- typedef vector<i64> vi64;
- typedef pair<int, int> pint;
- typedef pair<i64, i64> pi64;
- #define FILE_NAME "file"
- #define CONTEST "seq"
- #define M_PI 3.14159265358979323846
- #define ALL(a) (a).begin(), (a).end()
- const int inf = 1000000000;
- #define MOD 1000000007
- #define EPS 10E-10
- const int N = 2000000;
- int d[8002][8002];
- map<int, int> mp;
- int transfer[1000005];
- inline int getSum(int a, int b)
- {
- int y = transfer[a];
- int x = transfer[b];
- return d[y][x];
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout << fixed << setprecision(15);
- srand(16);
- int start = clock();
- #ifdef FILE_INPUT
- freopen(FILE_NAME ".in", "r", stdin);
- freopen(FILE_NAME ".out", "w", stdout);
- #endif
- int n;
- cin >> n;
- vector<pint> arr(n);
- forn(i, n)
- {
- cin >> arr[i].first >> arr[i].second;
- //arr[i].first = rand() % 1000000 + 1;
- //arr[i].second = rand() % 1000000 + 1;
- if (arr[i].first < arr[i].second)
- {
- swap(arr[i].first, arr[i].second);
- }
- mp[arr[i].first] = 1;
- mp[arr[i].second] = 1;
- }
- int j = 0;
- for (auto & i : mp)
- {
- i.second = j;
- transfer[i.first] = j;
- ++j;
- }
- forn(i, n)
- {
- d[mp[arr[i].first]][mp[arr[i].second]] ++;
- }
- down(i, 8001)
- {
- down(j, 8001)
- {
- d[i][j] += d[i][j + 1] + d[i + 1][j] - d[i + 1][j + 1];
- }
- }
- i64 ans = 0;
- i64 w = 0, h = 0;
- forn(i, n)
- {
- forn(q, 2)
- {
- for (int j = i; j < n; ++j)
- {
- forn(e, 2)
- {
- int a = arr[i].first;
- if (q)
- {
- a = arr[i].second;
- }
- int b = arr[j].first;
- if (e)
- {
- b = arr[j].second;
- }
- if (a < b)
- {
- swap(a, b);
- }
- i64 v = 0;
- v = getSum(a, b);
- v *= a;
- v *= b;
- if (v > ans)
- {
- ans = v;
- w = a;
- h = b;
- }
- }
- }
- }
- }
- cout << ans << "\n" << w << " " << h;
- //cerr << clock() - start;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement