HDU - 1029 Ignatius and the Princess IV

https://vjudge.net/problem/HDU-1029

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,tt;
	while(cin>>n)
	{
		int t,u,s=0;
		for(int i=0;i<n;i++)
		{
			cin>>t;
			if(s==0)
			{
				u=t;
				s++;
			}
			else if(t!=u)
				s--;
			else if(t==u)
				s++;
		}
		cout<<u<<"\n";
	}
	return 0;
}
posted @ 2021-08-19 21:25  斯文~  阅读(14)  评论(0)    收藏  举报

你好!