Advertisement
Guest User

B

a guest
Oct 17th, 2015
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.36 KB | None | 0 0
  1. #pragma warning (disable : 4996)
  2. #pragma comment(linker, "/STACK:36777216")
  3.  
  4.  
  5.  
  6. #include <stdlib.h>
  7. #include <iostream>
  8. #include <vector>
  9. #include <string>
  10. #include <assert.h>
  11. #include <stack>
  12. #include <algorithm>
  13. #include <ios>
  14. #include <iostream>
  15. #include <fstream>
  16. #include <iomanip>
  17. #include <queue>
  18. #include <set>
  19. #include <functional>
  20. #include <cmath>
  21. #include <sstream>
  22. #include <map>
  23. #include <memory.h>
  24. #include <stdio.h>
  25. #include <cassert>
  26. #include <string.h>
  27. #include <deque>
  28. #include <ctime>
  29. #include <unordered_map>
  30. #include <list>
  31.  
  32. #define forn(i , n) for (i64 i = 0; i < n; ++i)
  33. #define down(i, n) for (int i = (n) - 1; i >= 0; --i)
  34.  
  35.  
  36. using namespace std;
  37.  
  38. typedef unsigned long long int u64;
  39. typedef long long int i64;
  40. typedef vector<int> vint;
  41. typedef vector<i64> vi64;
  42. typedef pair<int, int> pint;
  43. typedef pair<i64, i64> pi64;
  44.  
  45. #define FILE_NAME "file"
  46. #define CONTEST "seq"
  47. #define M_PI 3.14159265358979323846
  48. #define ALL(a) (a).begin(), (a).end()
  49.  
  50.  
  51. const int inf = 1000000000;
  52.  
  53. #define MOD 1000000007
  54.  
  55.  
  56. #define EPS 10E-10
  57.  
  58. const int N = 2000000;
  59.  
  60.  
  61. int d[8002][8002];
  62.  
  63. map<int, int> mp;
  64. int transfer[1000005];
  65.  
  66.  
  67. inline int getSum(int a, int b)
  68. {
  69.     int y = transfer[a];
  70.     int x = transfer[b];
  71.     return d[y][x];
  72. }
  73.  
  74. int main()
  75. {
  76.     ios_base::sync_with_stdio(false);
  77.     cin.tie(NULL);
  78.     cout << fixed << setprecision(15);
  79.     srand(16);
  80.     int start = clock();
  81. #ifdef FILE_INPUT
  82.     freopen(FILE_NAME ".in", "r", stdin);
  83.     freopen(FILE_NAME ".out", "w", stdout);
  84. #endif
  85.  
  86.     int n;
  87.     cin >> n;
  88.     vector<pint> arr(n);
  89.  
  90.     forn(i, n)
  91.     {
  92.         cin >> arr[i].first >> arr[i].second;
  93.         //arr[i].first = rand() % 1000000 + 1;
  94.         //arr[i].second = rand() % 1000000 + 1;
  95.         if (arr[i].first < arr[i].second)
  96.         {
  97.             swap(arr[i].first, arr[i].second);
  98.         }
  99.         mp[arr[i].first] = 1;
  100.         mp[arr[i].second] = 1;
  101.  
  102.     }
  103.     int j = 0;
  104.     for (auto & i : mp)
  105.     {
  106.         i.second = j;
  107.         transfer[i.first] = j;
  108.  
  109.         ++j;
  110.     }
  111.     forn(i, n)
  112.     {
  113.         d[mp[arr[i].first]][mp[arr[i].second]] ++;
  114.  
  115.  
  116.     }
  117.     down(i, 8001)
  118.     {
  119.         down(j, 8001)
  120.         {
  121.             d[i][j] += d[i][j + 1] + d[i + 1][j] - d[i + 1][j + 1];
  122.         }
  123.     }
  124.     i64 ans = 0;
  125.     i64 w = 0, h = 0;
  126.     forn(i, n)
  127.     {
  128.         forn(q, 2)
  129.         {
  130.             for (int j = i; j < n; ++j)
  131.             {
  132.                 forn(e, 2)
  133.                 {
  134.                     int a = arr[i].first;
  135.                     if (q)
  136.                     {
  137.                         a = arr[i].second;
  138.                     }
  139.                     int b = arr[j].first;
  140.                     if (e)
  141.                     {
  142.                         b = arr[j].second;
  143.                     }
  144.                     if (a < b)
  145.                     {
  146.                         swap(a, b);
  147.                     }
  148.                     i64 v = 0;
  149.                     v = getSum(a, b);
  150.                     v *= a;
  151.                     v *= b;
  152.                     if (v > ans)
  153.                     {
  154.                         ans = v;
  155.                         w = a;
  156.                         h = b;
  157.                     }
  158.  
  159.  
  160.                 }
  161.             }
  162.         }
  163.     }
  164.     cout << ans << "\n" << w << " " << h;
  165.     //cerr << clock() - start;
  166.     return 0;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement