PavelAkovancev

отец

Feb 24th, 2021
790
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int* sort(int* x, int n)
  6. {
  7.     for (int i = 0; i < n + 1; i++) {
  8.         for (int j = 0; j < n + 1 - i; j++) {
  9.             if (x[j] > x[j + 1]) {
  10.                 int temp = x[j];
  11.                 x[j] = x[j + 1];
  12.                 x[j + 1] = temp;
  13.             }
  14.         }
  15.     }
  16.     return x;
  17. }
  18.  
  19. int d(int* x, int n)
  20. {
  21.     int dx = 0;
  22.     for (int i = 0; i < n - 1; i++)
  23.     {
  24.         if (x[i + 1] - x[i] > dx)
  25.         {
  26.             dx = x[i + 1] - x[i];
  27.         }
  28.     }
  29.     return dx;
  30. }
  31.  
  32. void Task()
  33. {
  34.     int w, h, n;
  35.     cin >> w >> h >> n;
  36.     int* x = new int[n + 2];
  37.     int* y = new int[n + 2];
  38.     for (int i = 0; i < n; i++) {
  39.         cin >> x[i] >> y[i];
  40.     }
  41.     x[n] = 0;
  42.     y[n] = 0;
  43.     x[n + 1] = w;
  44.     y[n + 1] = h;
  45.     x = sort(x, n);
  46.     y = sort(y, n);
  47.     int dx = d(x, n);
  48.     int dy = d(y, n);
  49.     cout << endl << (dx - 1) * (dy - 1) << endl;
  50. }
  51.  
  52. int main()
  53. {
  54.     setlocale(0, "");
  55.     Task();
  56.     return 0;
  57. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×