답안 #185650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
185650 2020-01-12T03:15:22 Z dndhk Bali Sculptures (APIO15_sculpture) C++14
71 / 100
497 ms 11064 KB
#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_N = 2000;
const int INF = 10000000;

int N, A, B;
vector<ll> v;
ll sum[MAX_N+1];
ll ans;

ll Sum(ll x, ll y){
	return sum[max(x, y)] - sum[min(x, y)-1];
}
vector<int> gp[MAX_N+1];
bool chk1[MAX_N+1], chk2[MAX_N+1];

bool check(ll x){
	for(int i=0; i<=N; i++){
		while(!gp[i].empty())	gp[i].pop_back();
	}
	for(int i=1; i<=N; i++){
		for(int j=i; j<=N; j++){
			if((Sum(i, j) | x) == x){
				gp[i-1].pb(j);
			}
		}
	}
	for(int i=0; i<=N; i++)	chk1[i] = chk2[i] = false;
	chk1[0] = true;
	for(int t=1; t<=B; t++){
		for(int i=0; i<=N; i++){
			if(chk1[i]){
				for(int j : gp[i]){
					chk2[j] = true;
				}
			}
		}
		for(int i=0; i<=N; i++){
			chk1[i] = chk2[i];
			chk2[i] = false;
		}
		if(t>=A && chk1[N])	return true;
	}
	return false;
}

void solve1(){
	ans = (1LL<<40LL)-1;
	for(int k=39; k>=0; k--){
		ll t = (1LL<<(ll)k);
		if(check(ans-t)){
			ans-=t;
		}
	}
}

int main(){
	scanf("%d%d%d", &N, &A, &B);
	v.pb(0LL);
	for(int i=1 ;i<=N; i++){
		ll x; scanf("%lld", &x);
		v.pb(x);
		sum[i]=sum[i-1]+v[i];
	}
	solve1();
	cout<<ans;
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &N, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 380 KB Output is correct
15 Correct 2 ms 448 KB Output is correct
16 Correct 2 ms 372 KB Output is correct
17 Correct 1 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 1 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 1 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 448 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 4 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 1 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 1 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 4 ms 376 KB Output is correct
28 Correct 3 ms 380 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 248 KB Output is correct
32 Correct 4 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 372 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 0 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 248 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 0 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 4 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 11 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 3 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 2 ms 380 KB Output is correct
38 Correct 4 ms 376 KB Output is correct
39 Correct 4 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 2 ms 248 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 0 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 3 ms 376 KB Output is correct
50 Correct 3 ms 376 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 3 ms 376 KB Output is correct
53 Correct 3 ms 376 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 3 ms 376 KB Output is correct
56 Correct 2 ms 376 KB Output is correct
57 Correct 3 ms 376 KB Output is correct
58 Correct 3 ms 376 KB Output is correct
59 Correct 4 ms 376 KB Output is correct
60 Correct 4 ms 376 KB Output is correct
61 Correct 3 ms 376 KB Output is correct
62 Correct 6 ms 376 KB Output is correct
63 Correct 4 ms 376 KB Output is correct
64 Correct 15 ms 376 KB Output is correct
65 Correct 3 ms 376 KB Output is correct
66 Correct 3 ms 376 KB Output is correct
67 Correct 3 ms 348 KB Output is correct
68 Correct 4 ms 376 KB Output is correct
69 Correct 6 ms 376 KB Output is correct
70 Correct 6 ms 376 KB Output is correct
71 Correct 3 ms 376 KB Output is correct
72 Correct 4 ms 376 KB Output is correct
73 Correct 7 ms 376 KB Output is correct
74 Correct 6 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 248 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 408 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 380 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 3 ms 424 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 2 ms 380 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 1 ms 420 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 3 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
38 Correct 4 ms 444 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 3 ms 376 KB Output is correct
44 Correct 3 ms 376 KB Output is correct
45 Correct 4 ms 376 KB Output is correct
46 Correct 4 ms 376 KB Output is correct
47 Correct 4 ms 404 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 3 ms 376 KB Output is correct
50 Correct 4 ms 376 KB Output is correct
51 Correct 3 ms 448 KB Output is correct
52 Correct 34 ms 1372 KB Output is correct
53 Correct 73 ms 2060 KB Output is correct
54 Correct 82 ms 3084 KB Output is correct
55 Correct 81 ms 3096 KB Output is correct
56 Correct 416 ms 11048 KB Output is correct
57 Correct 497 ms 11052 KB Output is correct
58 Correct 494 ms 7136 KB Output is correct
59 Correct 497 ms 7136 KB Output is correct
60 Incorrect 289 ms 11064 KB Output isn't correct
61 Halted 0 ms 0 KB -