URAL 1642 1D Maze

题目链接:点击打开链接

#include <cstdio>
int main() {
	int n, s, x;
	while(~scanf("%d%d", &n, &s)) {
		int l = - 1000, r = 1000;
		for(int i = 0; i < n; i ++) {
			scanf("%d", &x);
			if(x < 0 && x > l) l = x;
			if(x > 0 && x < r) r = x;
		}
		if(l > s || r < s) puts("Impossible");
		else {
			if(s > 0) printf("%d %d\n", s, l*(-2)+s);
			else printf("%d %d\n", r*2-s, -s);
		}
	}
	return 0;
}


你可能感兴趣的:(URAL 1642 1D Maze)