ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1642. 1D Maze

Egor Stepanov [mikroz] wa10 [4] // Problem 1642. 1D Maze 27 Oct 2008 18:39
I can't understand why... Please, help!
My algo :

  sort(x, x + n);

  int fp = 0;
  while (x[fp] < 0)
    ++fp;

  int fn = fp - 1;

  if (!(x[fn] <= p && p <= x[fp])) {
    printf("Impossible\n");
    return 0;
  }

  if (p > 0) {
    if (x[fp] > p) {
      printf("%d ", p);
    } else {
      printf("Impossible\n");
      return 0;
    }
  } else {
    if (x[fn] > p) {
      printf("Impossible\n");
      return 0;
    } else {
      printf("%d ", (2 * x[fp] - p));
    }
  }

  if (p < 0) {
    if (x[fn] > p) {
      printf("Impossible\n");
      return 0;
    } else {
      printf("%d\n", (-p));
    }
  } else {
    if (x[fp] < p) {
      printf("Impossible\n");
      return 0;
    } else {
      printf("%d\n", (p - 2 * x[fn]));
    }
  }
Elmurod Re: wa10 [3] // Problem 1642. 1D Maze 27 Oct 2008 20:06
give your mail i show you 2 variants ...
Egor Stepanov [mikroz] Re: wa10 [2] // Problem 1642. 1D Maze 27 Oct 2008 21:18
mikroz@gmail.com
thanks =)
Elmurod Re: wa10 [1] // Problem 1642. 1D Maze 31 Oct 2008 20:43
Egor Stepanov [mikroz] wrote 27 October 2008 21:18
mikroz@gmail.com
thanks =)
Sended
Nurtayev Elmurod Re: wa10 // Problem 1642. 1D Maze 3 Nov 2008 18:27
so do u understand? ;-)