PAT(甲级) 1006 (串的大小比较)

开始还在想着模拟做。。?这TM的串格式固定,直接比较!!!

#include
#include
#include
#include
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	//int st = 24 * 60 * 60 + 1;
	//int ed = -1;
	string st = "24:00:00";
	string ed = "00:00:00";
	string ans1, ans2;
	for (int i = 0; i < n; i++)
	{
		string ID;
		cin >> ID;
		string t;
		cin >> t;
		if (t < st) {
			st = t;
			ans1 = ID;
		}
		cin >> t;
		if (t > ed) {
			ed = t;
			ans2 = ID;
		}
	}
	cout << ans1 <<" " << ans2 << endl;
	return 0;
}

你可能感兴趣的:(PAT(甲级))