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

wa10
Posted by Egor Stepanov [mikroz] 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]));
    }
  }
Re: wa10
Posted by Elmurod 27 Oct 2008 20:06
give your mail i show you 2 variants ...
Re: wa10
Posted by Egor Stepanov [mikroz] 27 Oct 2008 21:18
mikroz@gmail.com
thanks =)
Re: wa10
Posted by Elmurod 31 Oct 2008 20:43
Egor Stepanov [mikroz] wrote 27 October 2008 21:18
mikroz@gmail.com
thanks =)
Sended
Re: wa10
Posted by Nurtayev Elmurod 3 Nov 2008 18:27
so do u understand? ;-)