fork(1) download
  1. # include <iostream>
  2. # include <cstdlib>
  3. # include <cstdio>
  4. # include <limits>
  5. # include <queue>
  6. # include <cmath>
  7. # include <algorithm>
  8. using namespace std;
  9. struct point
  10. {
  11. point (int X = 0, int Y = 0) {x = X; y = Y;}
  12. int x, y;
  13. };
  14. int cmp (point item1, point item2)
  15. {
  16. if (item1.x == item2.x)
  17. {
  18. return (item1.y <= item2.y);
  19. }
  20. return item1.x < item2.x;
  21. }
  22. /*int cmp (point item1, point item2)
  23. {
  24. if (item1.x <= item2.x)
  25. {
  26. return (item1.y <= item2.y);
  27. }
  28. return false;
  29. }*/
  30. point POINT[103];
  31. int MAXIM[103];
  32. int N, M, P, MCOUNT = 0, DIST = 0, LENGTH = 100;
  33. double DIAG = 141.42135623730950488016887242097;
  34. int main(int argc, char const *argv[])
  35. {
  36. //freopen ("1119_Metro_Input.txt", "r", stdin);
  37. //freopen ("1119_Metro_Output.txt","w", stdout);
  38. //while (cin.eof() == false)
  39. //{
  40. MCOUNT = 0;
  41. cin >> N >> M >> P;
  42. POINT[0].x = POINT[0].y = 0;
  43. MAXIM[0] = 0;
  44. for (int i = 1; i <= P; i++)
  45. {
  46. MAXIM[i] = 0;
  47. cin >> POINT[i].x >> POINT[i].y;
  48. }
  49. sort (POINT, POINT + P + 1, cmp);
  50. for (int i = 1; i <= P; i++)
  51. {
  52. for (int j = 0; j < i; j++)
  53. {
  54. if (POINT[j].x < POINT[i].x && POINT[j].y < POINT[i].y)
  55. MAXIM[i] = max (MAXIM [j] + 1, MAXIM[i]);
  56. }
  57. if (MAXIM[i] > MCOUNT)
  58. {
  59. MCOUNT = MAXIM[i];
  60. }
  61. }
  62. DIST = (N + M - (MCOUNT * 2)) * LENGTH;
  63. //cout << DIST << " " << MCOUNT << endl;
  64. cout << (int)((DIST + MCOUNT * DIAG) + 0.5) << endl;
  65. //}
  66. return 0;
  67. }
Success #stdin #stdout 0.01s 2732KB
stdin
3 2
3
1 1
3 2
1 2
stdout
383