cjweffort

博客园 首页 联系 订阅 管理
// 1041. Be Unique.cpp: 主项目文件。

#include "stdafx.h"
#include <cstdio>
#include <cstring>

const int arrMax=100003;
const int N=10003;
int arr[arrMax],hash[N],pos[N];

int main()
{
    int n;
	scanf("%d",&n);
	memset(hash,0,sizeof(hash));
	memset(pos,0,sizeof(pos));
	for(int i=0;i<n;i++){
		scanf("%d",arr+i);
		//can't add this unnecessary condition otherwise will time limit
		//if(hash[arr[i]]==0)
		pos[arr[i]]=i+1;
		hash[arr[i]]++;
	}
	int needPos=arrMax;
	for(int i=1;i<=10000;i++){
		if(hash[i]==1){
			if(pos[i]<needPos)
				needPos=pos[i];
		}
	}
	if(needPos==arrMax)
		printf("None\n");
	else
		printf("%d\n",arr[needPos-1]);
    return 0;
}

posted on 2013-03-13 18:51  cjweffort  阅读(170)  评论(0编辑  收藏  举报