Submission #395474

# Submission time Handle Problem Language Result Execution time Memory
395474 2021-04-28T11:42:27 Z bachaquer Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1000 ms 320 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           	 
# Verdict Execution time Memory 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 3 ms 204 KB Output is correct
7 Correct 1 ms 320 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 312 KB Output is correct
13 Correct 54 ms 312 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 3 ms 320 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 54 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 316 KB Output is correct
13 Correct 55 ms 312 KB Output is correct
14 Correct 144 ms 204 KB Output is correct
15 Correct 54 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Execution timed out 1093 ms 204 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 3 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 54 ms 296 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 1 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 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 224 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 208 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 54 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 25 ms 204 KB Output is correct
21 Correct 76 ms 312 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 75 ms 308 KB Output is correct
24 Correct 145 ms 308 KB Output is correct
25 Correct 53 ms 300 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Execution timed out 1094 ms 204 KB Time limit exceeded
28 Halted 0 ms 0 KB -