URAL 1644 A Whole Lot of Walnuts (水

题目链接:点击打开链接

题意略坑。。

#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	char s[15];
	int n, x;
	while(~scanf("%d", &n)) {
		int a = 2, b = 10;
		for(int i = 0; i < n; i ++) {
			scanf("%d %s", &x, s);
			if(s[0] == 'h') a = max(a, x);
			else b = min(b, x);
		}
		if(b <= a) puts("Inconsistent");
		else printf("%d\n", b);
	}
	return 0;
}
/*
4
4 hungry
7 satisfied
5 hungry
8 satisfied

2
6 hungry
5 satisfied

0

1
3 satisfied

*/


你可能感兴趣的:(URAL 1644 A Whole Lot of Walnuts (水)