Submission #26831

# Submission time Handle Problem Language Result Execution time Memory
26831 2017-07-06T08:18:10 Z yutaka1999 Hacker (BOI15_hac) C++14
100 / 100
166 ms 33268 KB
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define SIZE 500005

using namespace std;
typedef long long int ll;

ll sum[SIZE*2];
ll ans[SIZE*2];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		ll a;
		scanf("%lld",&a);
		sum[i]=a;
		if(i>0) sum[i]+=sum[i-1];
	}
	for(int i=n;i<2*n;i++) sum[i]=sum[n-1]+sum[i-n];
	for(int i=0;i<n;i++) ans[i]=sum[n-1];
	int L=(n+1)/2;
	priority_queue <ll,vector <ll>,greater <ll> > que,rem;
	for(int i=2*n-1;i>=L;i--)
	{
		if(i>=L-1) que.push(sum[i]-(i==L-1?0:sum[i-L]));
		if(i+L<=2*n-1) rem.push(sum[i+L]-sum[i]);
		while(!rem.empty()&&rem.top()==que.top()) que.pop(),rem.pop();
		ans[i%n]=min(ans[i%n],que.top());
	}
	ll ret=0;
	for(int i=0;i<n;i++) ret=max(ret,ans[i]);
	printf("%lld\n",ret);
	return 0;
}

Compilation message

hac.cpp: In function 'int main()':
hac.cpp:18:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
hac.cpp:22:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16796 KB Output is correct
2 Correct 0 ms 16796 KB Output is correct
3 Correct 0 ms 16796 KB Output is correct
4 Correct 0 ms 16796 KB Output is correct
5 Correct 0 ms 16796 KB Output is correct
6 Correct 0 ms 16796 KB Output is correct
7 Correct 0 ms 16796 KB Output is correct
8 Correct 0 ms 16796 KB Output is correct
9 Correct 0 ms 16796 KB Output is correct
10 Correct 0 ms 16796 KB Output is correct
11 Correct 0 ms 16796 KB Output is correct
12 Correct 0 ms 16796 KB Output is correct
13 Correct 0 ms 16796 KB Output is correct
14 Correct 0 ms 16796 KB Output is correct
15 Correct 0 ms 16796 KB Output is correct
16 Correct 0 ms 16796 KB Output is correct
17 Correct 0 ms 16796 KB Output is correct
18 Correct 0 ms 16796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16796 KB Output is correct
2 Correct 0 ms 16796 KB Output is correct
3 Correct 0 ms 16796 KB Output is correct
4 Correct 0 ms 16796 KB Output is correct
5 Correct 0 ms 16796 KB Output is correct
6 Correct 0 ms 16796 KB Output is correct
7 Correct 0 ms 16796 KB Output is correct
8 Correct 0 ms 16796 KB Output is correct
9 Correct 0 ms 16796 KB Output is correct
10 Correct 0 ms 16796 KB Output is correct
11 Correct 0 ms 16796 KB Output is correct
12 Correct 0 ms 16796 KB Output is correct
13 Correct 0 ms 16796 KB Output is correct
14 Correct 0 ms 16796 KB Output is correct
15 Correct 0 ms 16796 KB Output is correct
16 Correct 0 ms 16796 KB Output is correct
17 Correct 0 ms 16796 KB Output is correct
18 Correct 0 ms 16796 KB Output is correct
19 Correct 0 ms 16796 KB Output is correct
20 Correct 0 ms 16796 KB Output is correct
21 Correct 0 ms 16796 KB Output is correct
22 Correct 0 ms 16936 KB Output is correct
23 Correct 0 ms 16936 KB Output is correct
24 Correct 0 ms 16936 KB Output is correct
25 Correct 0 ms 16936 KB Output is correct
26 Correct 0 ms 16936 KB Output is correct
27 Correct 0 ms 16796 KB Output is correct
28 Correct 0 ms 16796 KB Output is correct
29 Correct 0 ms 16796 KB Output is correct
30 Correct 0 ms 16936 KB Output is correct
31 Correct 0 ms 16936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16796 KB Output is correct
2 Correct 0 ms 16796 KB Output is correct
3 Correct 0 ms 16936 KB Output is correct
4 Correct 19 ms 18928 KB Output is correct
5 Correct 69 ms 20972 KB Output is correct
6 Correct 96 ms 20972 KB Output is correct
7 Correct 73 ms 25072 KB Output is correct
8 Correct 133 ms 33268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16796 KB Output is correct
2 Correct 0 ms 16796 KB Output is correct
3 Correct 0 ms 16796 KB Output is correct
4 Correct 0 ms 16796 KB Output is correct
5 Correct 0 ms 16796 KB Output is correct
6 Correct 0 ms 16796 KB Output is correct
7 Correct 0 ms 16796 KB Output is correct
8 Correct 0 ms 16796 KB Output is correct
9 Correct 0 ms 16796 KB Output is correct
10 Correct 0 ms 16796 KB Output is correct
11 Correct 0 ms 16796 KB Output is correct
12 Correct 0 ms 16796 KB Output is correct
13 Correct 0 ms 16796 KB Output is correct
14 Correct 0 ms 16796 KB Output is correct
15 Correct 0 ms 16796 KB Output is correct
16 Correct 0 ms 16796 KB Output is correct
17 Correct 0 ms 16796 KB Output is correct
18 Correct 0 ms 16796 KB Output is correct
19 Correct 0 ms 16796 KB Output is correct
20 Correct 0 ms 16796 KB Output is correct
21 Correct 0 ms 16796 KB Output is correct
22 Correct 0 ms 16936 KB Output is correct
23 Correct 0 ms 16936 KB Output is correct
24 Correct 0 ms 16936 KB Output is correct
25 Correct 0 ms 16936 KB Output is correct
26 Correct 0 ms 16936 KB Output is correct
27 Correct 0 ms 16796 KB Output is correct
28 Correct 0 ms 16796 KB Output is correct
29 Correct 0 ms 16796 KB Output is correct
30 Correct 0 ms 16936 KB Output is correct
31 Correct 0 ms 16936 KB Output is correct
32 Correct 0 ms 16796 KB Output is correct
33 Correct 0 ms 16796 KB Output is correct
34 Correct 0 ms 16936 KB Output is correct
35 Correct 19 ms 18928 KB Output is correct
36 Correct 69 ms 20972 KB Output is correct
37 Correct 96 ms 20972 KB Output is correct
38 Correct 73 ms 25072 KB Output is correct
39 Correct 133 ms 33268 KB Output is correct
40 Correct 0 ms 17068 KB Output is correct
41 Correct 3 ms 17648 KB Output is correct
42 Correct 3 ms 17908 KB Output is correct
43 Correct 49 ms 23024 KB Output is correct
44 Correct 166 ms 33268 KB Output is correct
45 Correct 29 ms 18924 KB Output is correct
46 Correct 106 ms 25072 KB Output is correct
47 Correct 129 ms 33268 KB Output is correct
48 Correct 116 ms 19952 KB Output is correct
49 Correct 149 ms 25068 KB Output is correct
50 Correct 133 ms 25068 KB Output is correct