比赛 20191022轻松模拟测试 评测结果 AEEEEEEEEEE
题目名称 (USACO Dec18)平衡木 最终得分 9
用户昵称 CoolBoy小逴 运行时间 1.439 s
代码语言 C++ 内存使用 16.71 MiB
提交时间 2019-10-22 17:32:02
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define int long long
using namespace std;

const int maxn = 2e5 + 10;
const int eps = 100000;

int n, ans, l, r, qwq, pos;
int a[maxn], f[maxn];

int f_;
char ch_;
template <class T>
	inline T read(T &x_){
		x_ = 0, f_ = 1, ch_ = getchar();
		while (!isdigit(ch_)) {if (ch_ == '-') f_ = -1; ch_ = getchar();}
		while (isdigit(ch_)){x_ = (x_ << 3) + (x_ << 1) + ch_ - 48; ch_ = getchar();}
		return x_ *= f_;
	}

inline int Max (int x, int y){
	return (x > y) ? x : y;
}

signed main(){
	freopen ("balance_beam.in", "r", stdin);
	freopen ("balance_beam.out", "w", stdout);
	read(n);
	for (register int i = 1;i <= n; ++i) {
		read(a[i]);
		a[i] *= eps;
	}
	for (register int i = 1;i <= n; ++i) {
		pos = i;
		ans = a[i];
		l = pos-1;
		r = pos+1;
		qwq = 1;
		while (l >= 1) {
			qwq *= 2;
			ans = Max(ans, a[l]/qwq);
			--l;
		}
		qwq = 1;
		while (r <= n){
			qwq *= 2;
			ans = Max (ans, a[r]/qwq);
			++r;
		}
		printf ("%lld\n", ans);
	}
	return 0;
}