Submission #55149

# Submission time Handle Problem Language Result Execution time Memory
55149 2018-07-06T06:37:18 Z khsoo01(#2065) None (JOI14_ho_t3) C++11
100 / 100
262 ms 3068 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 100005, inf = 1e18;

ll n, a[2*N], nxt[N];

bool can (ll V) {
	for(ll S=0, E=-1, X=0; S < n;) {
		if(X >= V || E - S >= n-1) {
			nxt[S] = E+1;
			X -= a[S];
			S++;
		}
		else {
			E++;
			X += a[E];
		}
	}
	for(ll i=0;i<n;i++) {
		ll C = i, L = 0;
		for(ll j=0;j<3;j++) {
			L += nxt[C] - C;
			C = nxt[C] % n;
		}
		if(L <= n) return true;
	}
	return false;
}

int main()
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		a[i+n] = a[i];
	}
	ll S = 0, E = inf;
	while(S<E) {
		ll M = (S+E)/2+1;
		can(M) ? S = M : E = M-1;
	}
	printf("%lld\n",S);
}

Compilation message

2014_ho_t3.cpp: In function 'int main()':
2014_ho_t3.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
  ~~~~~^~~~~~~~~~~
2014_ho_t3.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 3 ms 716 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 3 ms 716 KB Output is correct
16 Correct 4 ms 716 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 716 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 3 ms 716 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 3 ms 716 KB Output is correct
16 Correct 4 ms 716 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 716 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
21 Correct 26 ms 764 KB Output is correct
22 Correct 20 ms 764 KB Output is correct
23 Correct 18 ms 768 KB Output is correct
24 Correct 19 ms 768 KB Output is correct
25 Correct 20 ms 768 KB Output is correct
26 Correct 18 ms 768 KB Output is correct
27 Correct 21 ms 768 KB Output is correct
28 Correct 21 ms 768 KB Output is correct
29 Correct 20 ms 768 KB Output is correct
30 Correct 21 ms 768 KB Output is correct
31 Correct 16 ms 768 KB Output is correct
32 Correct 19 ms 768 KB Output is correct
33 Correct 17 ms 832 KB Output is correct
34 Correct 23 ms 832 KB Output is correct
35 Correct 20 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 564 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 2 ms 640 KB Output is correct
7 Correct 2 ms 692 KB Output is correct
8 Correct 2 ms 692 KB Output is correct
9 Correct 3 ms 692 KB Output is correct
10 Correct 2 ms 692 KB Output is correct
11 Correct 3 ms 716 KB Output is correct
12 Correct 3 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 3 ms 716 KB Output is correct
16 Correct 4 ms 716 KB Output is correct
17 Correct 3 ms 716 KB Output is correct
18 Correct 3 ms 716 KB Output is correct
19 Correct 4 ms 716 KB Output is correct
20 Correct 3 ms 716 KB Output is correct
21 Correct 26 ms 764 KB Output is correct
22 Correct 20 ms 764 KB Output is correct
23 Correct 18 ms 768 KB Output is correct
24 Correct 19 ms 768 KB Output is correct
25 Correct 20 ms 768 KB Output is correct
26 Correct 18 ms 768 KB Output is correct
27 Correct 21 ms 768 KB Output is correct
28 Correct 21 ms 768 KB Output is correct
29 Correct 20 ms 768 KB Output is correct
30 Correct 21 ms 768 KB Output is correct
31 Correct 16 ms 768 KB Output is correct
32 Correct 19 ms 768 KB Output is correct
33 Correct 17 ms 832 KB Output is correct
34 Correct 23 ms 832 KB Output is correct
35 Correct 20 ms 832 KB Output is correct
36 Correct 228 ms 2968 KB Output is correct
37 Correct 214 ms 2968 KB Output is correct
38 Correct 185 ms 2972 KB Output is correct
39 Correct 202 ms 2972 KB Output is correct
40 Correct 213 ms 2972 KB Output is correct
41 Correct 262 ms 3068 KB Output is correct
42 Correct 181 ms 3068 KB Output is correct
43 Correct 206 ms 3068 KB Output is correct
44 Correct 177 ms 3068 KB Output is correct
45 Correct 252 ms 3068 KB Output is correct
46 Correct 180 ms 3068 KB Output is correct
47 Correct 181 ms 3068 KB Output is correct
48 Correct 204 ms 3068 KB Output is correct