Guest User

B

a guest
Oct 17th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.29 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.  
  65. inline int getSum(int a, int b)
  66. {
  67.     int y = mp[a];
  68.     int x = mp[b];
  69.     return d[y][x];
  70. }
  71.  
  72. int main()
  73. {
  74.     ios_base::sync_with_stdio(false);
  75.     cin.tie(NULL);
  76.     cout << fixed << setprecision(15);
  77.     srand(16);
  78.     int start = clock();
  79. #ifdef FILE_INPUT
  80.     freopen(FILE_NAME ".in", "r", stdin);
  81.     freopen(FILE_NAME ".out", "w", stdout);
  82. #endif
  83.    
  84.     int n;
  85.     cin >> n;
  86.     vector<pint> arr(n);
  87.    
  88.     forn(i, n)
  89.     {
  90.         cin >> arr[i].first >> arr[i].second;
  91.         //arr[i].first = rand() % 1000000 + 1;
  92.         //arr[i].second = rand() % 1000000 + 1;
  93.         if (arr[i].first < arr[i].second)
  94.         {
  95.             swap(arr[i].first, arr[i].second);
  96.         }
  97.         mp[arr[i].first] = 1;
  98.         mp[arr[i].second] = 1;
  99.     }
  100.     int j = 0;
  101.     for (auto & i : mp)
  102.     {
  103.         i.second = j;
  104.         ++j;
  105.     }
  106.     forn(i, n)
  107.     {
  108.         d[mp[arr[i].first]][mp[arr[i].second]] ++;
  109.  
  110.  
  111.     }
  112.     down(i, 8001)
  113.     {
  114.         down(j, 8001)
  115.         {
  116.             d[i][j] += d[i][j + 1] + d[i + 1][j] - d[i + 1][j + 1];
  117.         }
  118.     }
  119.     i64 ans = 0;
  120.     i64 w = 0, h = 0;
  121.     forn(i, n)
  122.     {
  123.         forn(q, 2)
  124.         {
  125.             for (int j = i; j < n; ++j)
  126.             {
  127.                 forn(e, 2)
  128.                 {
  129.                     int a = arr[i].first;
  130.                     if (q)
  131.                     {
  132.                         a = arr[i].second;
  133.                     }
  134.                     int b = arr[j].first;
  135.                     if (e)
  136.                     {
  137.                         b = arr[j].second;
  138.                     }
  139.                     if (a < b)
  140.                     {
  141.                         swap(a, b);
  142.                     }
  143.                     i64 v = 0;
  144.                     v = getSum(a, b);
  145.                     v *= a;
  146.                     v *= b;
  147.                     if (v > ans)
  148.                     {
  149.                         ans = v;
  150.                         w = a;
  151.                         h = b;
  152.                     }
  153.  
  154.  
  155.                 }
  156.             }
  157.         }
  158.     }
  159.     cout << ans << "\n" << w << " " << h;
  160.     //cerr << clock() - start;
  161.     return 0;
  162. }
Advertisement
Add Comment
Please, Sign In to add comment