Submission #909400

#TimeUsernameProblemLanguageResultExecution timeMemory
909400shoryu386Hacker (BOI15_hac)C++17
40 / 100
1038 ms4440 KiB
#include <bits/stdc++.h>
using namespace std;
#define MAX 200007
#define int long long
main(){
	int n; cin >> n;
	
	int count = (n+1)/2;
	
	int arr[2*n];
	for (int x = 0; x < n; x++) cin >> arr[x];
	for (int x = 0; x < n; x++) arr[n + x] = arr[x];
	
	
	int hmm[2*n]; memset(hmm, 63, sizeof(hmm));
	int sums[2*n];
	for (int x = 0; x < 2*n; x++){
		int sum = 0;
		for (int y = x; y < x+count; y++){
			sum += arr[y%n];
		}
		sums[x] = sum;
	}
	
	multiset<int> ms;
	for (int x = 0; x < count; x++){
		ms.insert(sums[x]);
	}
	
	memset(hmm, -63, sizeof(hmm));
	hmm[0] = *ms.begin();
	
	for (int x = 1; x < n; x++){
		ms.insert(sums[count+x-1]);
		ms.erase(ms.find(sums[x-1]));
		
		hmm[x] = *ms.begin();
	}
	
	int ans = INT_MIN;
	for (int x = 0; x < n; x++){
		ans = max(ans, hmm[x]);
	}
	cout << ans;
}

Compilation message (stderr)

hac.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...