제출 #251752

#제출 시각아이디문제언어결과실행 시간메모리
251752tutisHacker (BOI15_hac)C++17
0 / 100
1 ms384 KiB
/*input
4
7 6 8 4
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename K>
using ordered_map = tree<T, K, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	ll h[n];
	for (int i = 0; i < n; i++)
		cin >> h[i];
	if (n == 2)
	{
		cout << max(h[0], h[1]) << "\n";
		return 0;
	}
	int k = (n + 1) / 2;
	ll s[2 * n + 6];
	s[0] = 0;
	for (int i = 1; i <= 2 * n + 5; i++)
		s[i] = s[i - 1] + h[(i - 1) % n];
	ll ans = 0;
	for (int i = k + 1; i <= 2 * n + 5; i++)
	{
		ans = max(ans, min(s[i] - s[i - k], s[i - 1] - s[i - 1 - k]));
	}
	cout << ans << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...