답안 #395478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
395478 2021-04-28T11:47:14 Z bachaquer Bali Sculptures (APIO15_sculpture) C++14
9 / 100
1000 ms 324 KB
#include <bits/stdc++.h>
/*
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
using namespace std;

#define F first
#define S second
#define pb push_back    
#define nl '\n'
#define all(z) (z).begin(), (z).end()
#define sz(x) (int) (x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long ll;

long long n, m, a, b, y, x, k, ti, h;
string s, ss;
char c, ch;
long double db;                                                            
                                                                           
const int N = 1e5 + 7;                                                     
const int INF = INT_MAX;                                                   
int mod = 1e9 + 7;

vector<ll> v, pref;
ll ans = LLONG_MAX;
ll cur = 0;
ll cnt = 0;    

void solve(int st, int prev) {
	cnt++;
	if (cnt == k) {
		ll noww = cur;
		cur |= (pref[n] - pref[prev]);
		ans = min(ans, cur);
		cur = noww;
		cnt--;
		return;
	}
	ll now = cur;
	for (int i = st; i < n; ++i) {
		cur |= (pref[i] - pref[prev]);
		solve(i + 1, i);
		cur = now;
	}
	cnt--;
}

void Main() {
	cin >> n >> a >> b;
	v.resize(n + 1);
	pref.assign(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> v[i];
		pref[i] = pref[i - 1] + v[i];
	}
	for (int i = a; i <= b; ++i) {
		k = i;
		solve(1, 0);
	}
	cout << ans;
	return;
}

int main () {                                                                           
    IOS;
#ifdef BATYA
    freopen(".in", "r", stdin);
#endif
	ti = 1;
	//cin >> ti;
	while (ti--)
		Main();
	return 0;	
}

//doner           	 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 30 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 15 ms 320 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 316 KB Output is correct
33 Correct 14 ms 316 KB Output is correct
34 Correct 40 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 47 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 29 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 320 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 15 ms 316 KB Output is correct
27 Correct 80 ms 308 KB Output is correct
28 Correct 38 ms 204 KB Output is correct
29 Correct 2 ms 208 KB Output is correct
30 Execution timed out 1094 ms 204 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 29 ms 316 KB Output is correct
14 Correct 78 ms 204 KB Output is correct
15 Correct 37 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Execution timed out 1090 ms 204 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 29 ms 320 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 2 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 15 ms 312 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 316 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 14 ms 312 KB Output is correct
34 Correct 41 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 40 ms 204 KB Output is correct
37 Correct 76 ms 296 KB Output is correct
38 Correct 37 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Execution timed out 1089 ms 204 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 29 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 16 ms 204 KB Output is correct
21 Correct 40 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 41 ms 296 KB Output is correct
24 Correct 77 ms 296 KB Output is correct
25 Correct 37 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Execution timed out 1084 ms 208 KB Time limit exceeded
28 Halted 0 ms 0 KB -