fork download
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
  9. String[] params1 = bufferedReader.readLine().split(" ");
  10. int max_page_size = 210;
  11. boolean[][] squares = new boolean[max_page_size][max_page_size];
  12. for (int i = 0; i < max_page_size; ++i){
  13. for (int j = 0; j < max_page_size; ++j){
  14. squares[i][j] = false;
  15. }
  16. }
  17. int n;
  18. n = Integer.parseInt(params1[0]);
  19. for (int i = 0; i < n; ++i){
  20. String[] params2 = bufferedReader.readLine().split(" ");
  21. int x, y;
  22. x = Integer.parseInt(params2[0]);
  23. y = Integer.parseInt(params2[1]);
  24. squares[x + max_page_size / 2][y + max_page_size / 2] = true;
  25. }
  26. int perimiter = 0;
  27. for (int i = 0; i < max_page_size; ++i){
  28. for (int j = 0; j < max_page_size; ++j){
  29. if (squares[i][j]){
  30. perimiter += (!squares[i + 1][j] ? 1 : 0) + (!squares[i - 1][j] ? 1 : 0) + (!squares[i][j + 1] ? 1 : 0) + (!squares[i][j - 1] ? 1 : 0);
  31. }
  32. }
  33. }
  34. int max = 0;
  35. for (int j = 1; (perimiter - 2 * j) / 2 > 0; ++j){
  36. int i = (perimiter - 2 * j) / 2;
  37. if (i * j - n > max) {
  38. max = i * j - n;
  39. }
  40. }
  41. System.out.print(max);
  42. }
  43. }
Success #stdin #stdout 0.05s 2184192KB
stdin
3
1 2
2 1
3 1
stdout
3