您的位置:首页 > 其它

模拟 之 Codeforces 416A

2014-04-13 23:56 423 查看
//  [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;
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: