Submission #893116

# Submission time Handle Problem Language Result Execution time Memory
893116 2023-12-26T14:25:00 Z LCJLY Hacker (BOI15_hac) C++14
20 / 100
41 ms 18264 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl; 
#define show4(x,y) for(auto it:x) cout << it << " "; cout << #y << endl;
typedef pair<int,int>pii;
typedef pair<pii,pii>pi2;

void solve(){	
	int n;
	cin >> n;
	int arr[2*n+1];
	for(int x=1;x<=n;x++){
		cin >> arr[x];
		arr[x+n]=arr[x];
	}
	
	int prefix[2*n+1];
	memset(prefix,0,sizeof(prefix));
	for(int x=1;x<=2*n;x++){
		prefix[x]=prefix[x-1]+arr[x];
	}
	
	int k=(n+1)/2;
	
	//int ptr=k;
	//deque<pii>d;
	//int best=0;
	//for(int x=1;x<=2*n;x++){
		//while(ptr<=2*n&&ptr<=x+k-1){
			//while(!d.empty()&&d.back().first>prefix[ptr]-prefix[ptr-k]){
				//d.pop_back();
			//}
			//d.push_back({prefix[ptr]-prefix[ptr-k],ptr});
			//ptr++;
		//}
		
		//while(!d.empty()&&d.front().second<x) d.pop_front();
		
		//if(!d.empty())best=max(best,d.front().first);
	//}
	//cout << best;
	
	int mini=LONG_LONG_MAX;
	for(int x=n+1;x<=n+k;x++){
		mini=min(mini,prefix[x]-prefix[x-k]);
	}
	
	cout << mini;
}

int32_t main(){										
	ios::sync_with_stdio(0);	
	cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}	
}



		


		
		
	
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 8 ms 3096 KB Output is correct
5 Correct 14 ms 7260 KB Output is correct
6 Correct 18 ms 9560 KB Output is correct
7 Correct 22 ms 11360 KB Output is correct
8 Correct 41 ms 18264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -