模拟 之 Codeforces 416A

来源:互联网 发布:.wang域名 编辑:程序博客网 时间:2024/06/04 18:31
//  [4/13/2014 Sjm]/*关键: 寻找 左右区间,判断此区间是否合理。*/
#include <iostream>#include <cstdio>#include <cstdlib>#include <string>#include <algorithm>using namespace std;const int MAX = 2000000000, MIN = -2000000000;int main(){//freopen("input.txt", "r", stdin);//freopen("output.txt", "w", stdout);int n, lef = MIN, rig = MAX, temp;string str;char c;scanf("%d", &n);while (n--){cin >> str;scanf("%d %c", &temp, &c);if ('N' == c) {if (">" == str) str = "<=";else {if ("<" == str) str = ">=";else {if ("<=" == str) str = ">";else str = "<";}}}if (">" == str) lef = max(lef, temp + 1);else {if ("<" == str) rig = min(rig, temp - 1);else {if (">=" == str) lef = max(lef, temp);else rig = min(rig, temp);}}}if (lef > rig) printf("Impossible\n");else printf("%d\n", lef);return 0;}


0 0