记录编号 175595 评测结果 AEEEEAAAAAAAEEE
题目名称 767.[USACO Open12] 淹没岛屿 最终得分 53
用户昵称 啊吧啦吧啦吧 是否通过 未通过
代码语言 C++ 运行时间 1.864 s
提交时间 2015-08-06 14:47:50 内存使用 0.70 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <ctime>
//#define self

using namespace std;
typedef set<int> si;
typedef vector<int> vi;

const int MAXN(100001);
int n, h[MAXN], ans = 1;
si ah;

inline int in(){
	int x = 0;
	char c;
	while(! isdigit(c = getchar()));
	while(isdigit(c)){
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x;
}

main()
{
#ifndef self
	FILE *fout;
	freopen("islands.in", "r", stdin);
	fout = fopen("islands.out", "w");
#endif
	n = in();
	int t = 0;
	for (int i = 1; i <= n; ++i){
		h[i] = in();
		ah.insert(h[i]);
	}
	
	for (si::iterator it = ah.begin(); it != ah.end(); ++it){
		if (t >= 7000000){
#ifdef self
			cout << ans;
			for(;;);
#else
			fprintf(fout, "%d", ans);
			fclose(stdin);
			fclose(fout);
#endif
		}
		int i = 1, na = 0;
		bool is;
		while (i <= n){
			++t;
			if (h[i] <= *it){
				++i;
				continue;
			}
			na++;
			is = true;
			break;
		}
		for (; i <= n; ++i){
			++t;
			if (h[i] > *it && (! is)){
				is = true;
				na++;
			}
			else if (h[i] <= *it && is)
				is = false;
		}
		ans = max(ans, na);
	}
	
#ifdef self
	cout << ans;
	for(;;);
#else
	fprintf(fout, "%d", ans);
	fclose(stdin);
	fclose(fout);
#endif
}