fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #define MAX_PAGE_SIZE 210
  5.  
  6. int squares[MAX_PAGE_SIZE][MAX_PAGE_SIZE];
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. for (int i = 0; i < n; ++i){ int x, y; cin >> x >> y;
  12. squares[x + MAX_PAGE_SIZE / 2][y + MAX_PAGE_SIZE / 2] = 1;
  13. }
  14. int perimiter = 0;
  15. for (int i = 0; i < MAX_PAGE_SIZE; ++i){
  16. for (int j = 0; j < MAX_PAGE_SIZE; ++j){
  17. if (squares[i][j]){
  18. perimiter += !squares[i + 1][j] + !squares[i - 1][j] + !squares[i][j + 1] + !squares[i][j - 1];
  19. }
  20. }
  21. }
  22. int max = 0;
  23. for (int j = 1; (perimiter - 2 * j) / 2 > 0; ++j){
  24. int i = (perimiter - 2 * j) / 2;
  25. if (i * j - n > max) {
  26. max = i * j - n;
  27. }
  28. }
  29. cout << max;
  30. return 0;
  31. }
Success #stdin #stdout 0s 4556KB
stdin
3
1 2
2 1
3 1
stdout
3