#include<bits/stdc++.h>
using namespace std;
#define in ({ll x=0;int n=0,c=getchar();for(;!isdigit(c);c=getchar()) n=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})
#define ll long long
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)
#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second
#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1
#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
#define bitnum(x) __builtin_popcountll(x)
////////////////////////////////////////// NIRO
#define int ll
const int N=2005;
int n,A,B;
ll a[N];
int s[N];
int f[N][N];
ll all;
ll SUM(int u,int v){ll res=s[v]-s[u-1];return (res&all)==0;}
main()
{
//freopen("nr.inp","r",stdin);
n=in,A=in,B=in;
FOR(i,1,n) a[i]=in;
FOR(i,1,n) s[i]=s[i-1]+a[i];
ROF(bit,1,41)
{
all=on(all,bit);
if(n<=100)
{
memset(f,0,sizeof f);
FOR(i,1,n) f[i][1]=SUM(1,i);
FOR(i,1,n) FOR(j,2,B){
FOR(k,1,i-1) if(f[k][j-1]&&SUM(k+1,i)) f[i][j]=1;
}
all=off(all,bit);
FOR(i,A,B) if(f[n][i]) all=on(all,bit);
}
else
{
ll sum=0,cnt=0;
FOR(i,1,n)
{
sum+=a[i];
if((sum&all)!=0) sum=a[i],cnt++;
}
cnt++;
all=off(all,bit);
if(cnt<=B) all=on(all,bit);
}
}
FOR(i,1,41) {if(bit(all,i)) all=off(all,i);else all=on(all,i);}
cout<<all;
}
Compilation message
sculpture.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
244 ms |
31964 KB |
Output is correct |
2 |
Correct |
245 ms |
31864 KB |
Output is correct |
3 |
Correct |
246 ms |
31932 KB |
Output is correct |
4 |
Correct |
275 ms |
31828 KB |
Output is correct |
5 |
Correct |
242 ms |
31864 KB |
Output is correct |
6 |
Correct |
290 ms |
31864 KB |
Output is correct |
7 |
Correct |
252 ms |
31992 KB |
Output is correct |
8 |
Correct |
247 ms |
31864 KB |
Output is correct |
9 |
Correct |
241 ms |
31864 KB |
Output is correct |
10 |
Correct |
244 ms |
31864 KB |
Output is correct |
11 |
Correct |
249 ms |
31864 KB |
Output is correct |
12 |
Correct |
253 ms |
31736 KB |
Output is correct |
13 |
Correct |
246 ms |
31836 KB |
Output is correct |
14 |
Correct |
248 ms |
31992 KB |
Output is correct |
15 |
Correct |
247 ms |
31864 KB |
Output is correct |
16 |
Correct |
266 ms |
31864 KB |
Output is correct |
17 |
Correct |
248 ms |
31876 KB |
Output is correct |
18 |
Correct |
240 ms |
31864 KB |
Output is correct |
19 |
Correct |
251 ms |
31992 KB |
Output is correct |
20 |
Correct |
244 ms |
31864 KB |
Output is correct |
21 |
Correct |
237 ms |
31868 KB |
Output is correct |
22 |
Correct |
255 ms |
31992 KB |
Output is correct |
23 |
Correct |
247 ms |
31864 KB |
Output is correct |
24 |
Correct |
231 ms |
31864 KB |
Output is correct |
25 |
Correct |
239 ms |
31864 KB |
Output is correct |
26 |
Correct |
375 ms |
31888 KB |
Output is correct |
27 |
Correct |
287 ms |
31864 KB |
Output is correct |
28 |
Correct |
228 ms |
31864 KB |
Output is correct |
29 |
Correct |
244 ms |
31904 KB |
Output is correct |
30 |
Correct |
237 ms |
31864 KB |
Output is correct |
31 |
Correct |
237 ms |
31764 KB |
Output is correct |
32 |
Correct |
242 ms |
31864 KB |
Output is correct |
33 |
Correct |
227 ms |
31736 KB |
Output is correct |
34 |
Correct |
239 ms |
31832 KB |
Output is correct |
35 |
Correct |
240 ms |
31976 KB |
Output is correct |
36 |
Correct |
250 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
239 ms |
31832 KB |
Output is correct |
2 |
Correct |
237 ms |
31864 KB |
Output is correct |
3 |
Correct |
239 ms |
31736 KB |
Output is correct |
4 |
Correct |
248 ms |
31864 KB |
Output is correct |
5 |
Correct |
237 ms |
31864 KB |
Output is correct |
6 |
Correct |
234 ms |
31864 KB |
Output is correct |
7 |
Correct |
237 ms |
31872 KB |
Output is correct |
8 |
Correct |
256 ms |
31872 KB |
Output is correct |
9 |
Correct |
236 ms |
31864 KB |
Output is correct |
10 |
Correct |
253 ms |
31864 KB |
Output is correct |
11 |
Correct |
244 ms |
31900 KB |
Output is correct |
12 |
Correct |
245 ms |
31864 KB |
Output is correct |
13 |
Correct |
247 ms |
31736 KB |
Output is correct |
14 |
Correct |
244 ms |
31736 KB |
Output is correct |
15 |
Correct |
246 ms |
31864 KB |
Output is correct |
16 |
Correct |
240 ms |
31864 KB |
Output is correct |
17 |
Correct |
235 ms |
31736 KB |
Output is correct |
18 |
Correct |
239 ms |
31864 KB |
Output is correct |
19 |
Correct |
244 ms |
31736 KB |
Output is correct |
20 |
Correct |
243 ms |
31864 KB |
Output is correct |
21 |
Correct |
248 ms |
31864 KB |
Output is correct |
22 |
Correct |
242 ms |
31864 KB |
Output is correct |
23 |
Correct |
227 ms |
31864 KB |
Output is correct |
24 |
Correct |
222 ms |
31992 KB |
Output is correct |
25 |
Correct |
238 ms |
31836 KB |
Output is correct |
26 |
Correct |
234 ms |
31864 KB |
Output is correct |
27 |
Correct |
272 ms |
31864 KB |
Output is correct |
28 |
Correct |
245 ms |
31944 KB |
Output is correct |
29 |
Correct |
238 ms |
31864 KB |
Output is correct |
30 |
Correct |
243 ms |
31740 KB |
Output is correct |
31 |
Correct |
233 ms |
31864 KB |
Output is correct |
32 |
Correct |
237 ms |
31864 KB |
Output is correct |
33 |
Correct |
257 ms |
31864 KB |
Output is correct |
34 |
Correct |
238 ms |
31988 KB |
Output is correct |
35 |
Correct |
242 ms |
31840 KB |
Output is correct |
36 |
Correct |
263 ms |
31736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
238 ms |
31864 KB |
Output is correct |
2 |
Correct |
237 ms |
31836 KB |
Output is correct |
3 |
Correct |
231 ms |
31964 KB |
Output is correct |
4 |
Correct |
235 ms |
31848 KB |
Output is correct |
5 |
Correct |
248 ms |
31864 KB |
Output is correct |
6 |
Correct |
263 ms |
31864 KB |
Output is correct |
7 |
Correct |
249 ms |
31736 KB |
Output is correct |
8 |
Correct |
239 ms |
31736 KB |
Output is correct |
9 |
Correct |
240 ms |
31736 KB |
Output is correct |
10 |
Correct |
243 ms |
31868 KB |
Output is correct |
11 |
Correct |
245 ms |
31736 KB |
Output is correct |
12 |
Correct |
249 ms |
31864 KB |
Output is correct |
13 |
Correct |
248 ms |
31964 KB |
Output is correct |
14 |
Correct |
243 ms |
31864 KB |
Output is correct |
15 |
Correct |
258 ms |
31964 KB |
Output is correct |
16 |
Correct |
231 ms |
31868 KB |
Output is correct |
17 |
Correct |
236 ms |
31864 KB |
Output is correct |
18 |
Correct |
233 ms |
31864 KB |
Output is correct |
19 |
Correct |
228 ms |
31836 KB |
Output is correct |
20 |
Correct |
236 ms |
31740 KB |
Output is correct |
21 |
Correct |
229 ms |
31736 KB |
Output is correct |
22 |
Correct |
236 ms |
31736 KB |
Output is correct |
23 |
Correct |
233 ms |
31864 KB |
Output is correct |
24 |
Correct |
240 ms |
31736 KB |
Output is correct |
25 |
Correct |
307 ms |
31736 KB |
Output is correct |
26 |
Correct |
262 ms |
31992 KB |
Output is correct |
27 |
Correct |
250 ms |
31836 KB |
Output is correct |
28 |
Correct |
269 ms |
31864 KB |
Output is correct |
29 |
Correct |
268 ms |
31848 KB |
Output is correct |
30 |
Correct |
228 ms |
31736 KB |
Output is correct |
31 |
Correct |
242 ms |
31844 KB |
Output is correct |
32 |
Correct |
255 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
234 ms |
31840 KB |
Output is correct |
2 |
Correct |
226 ms |
31832 KB |
Output is correct |
3 |
Correct |
251 ms |
31864 KB |
Output is correct |
4 |
Correct |
366 ms |
31864 KB |
Output is correct |
5 |
Correct |
238 ms |
31864 KB |
Output is correct |
6 |
Correct |
217 ms |
31992 KB |
Output is correct |
7 |
Correct |
269 ms |
31864 KB |
Output is correct |
8 |
Correct |
294 ms |
31864 KB |
Output is correct |
9 |
Correct |
243 ms |
31872 KB |
Output is correct |
10 |
Correct |
240 ms |
31736 KB |
Output is correct |
11 |
Correct |
242 ms |
31736 KB |
Output is correct |
12 |
Correct |
236 ms |
31864 KB |
Output is correct |
13 |
Correct |
240 ms |
31864 KB |
Output is correct |
14 |
Correct |
237 ms |
31736 KB |
Output is correct |
15 |
Correct |
242 ms |
31736 KB |
Output is correct |
16 |
Correct |
242 ms |
31736 KB |
Output is correct |
17 |
Correct |
243 ms |
31840 KB |
Output is correct |
18 |
Correct |
310 ms |
31864 KB |
Output is correct |
19 |
Correct |
245 ms |
31736 KB |
Output is correct |
20 |
Correct |
241 ms |
31864 KB |
Output is correct |
21 |
Correct |
236 ms |
31864 KB |
Output is correct |
22 |
Correct |
239 ms |
31960 KB |
Output is correct |
23 |
Correct |
226 ms |
31864 KB |
Output is correct |
24 |
Correct |
258 ms |
31992 KB |
Output is correct |
25 |
Correct |
366 ms |
31864 KB |
Output is correct |
26 |
Correct |
225 ms |
31864 KB |
Output is correct |
27 |
Correct |
236 ms |
31864 KB |
Output is correct |
28 |
Correct |
222 ms |
31864 KB |
Output is correct |
29 |
Correct |
227 ms |
31872 KB |
Output is correct |
30 |
Correct |
225 ms |
31864 KB |
Output is correct |
31 |
Correct |
267 ms |
31992 KB |
Output is correct |
32 |
Correct |
207 ms |
31864 KB |
Output is correct |
33 |
Correct |
241 ms |
31864 KB |
Output is correct |
34 |
Correct |
239 ms |
31864 KB |
Output is correct |
35 |
Correct |
225 ms |
31736 KB |
Output is correct |
36 |
Correct |
241 ms |
31992 KB |
Output is correct |
37 |
Correct |
233 ms |
31736 KB |
Output is correct |
38 |
Correct |
244 ms |
31864 KB |
Output is correct |
39 |
Correct |
242 ms |
31864 KB |
Output is correct |
40 |
Correct |
247 ms |
31864 KB |
Output is correct |
41 |
Correct |
242 ms |
31864 KB |
Output is correct |
42 |
Correct |
225 ms |
31868 KB |
Output is correct |
43 |
Correct |
251 ms |
31924 KB |
Output is correct |
44 |
Correct |
311 ms |
31992 KB |
Output is correct |
45 |
Correct |
245 ms |
31992 KB |
Output is correct |
46 |
Correct |
250 ms |
31864 KB |
Output is correct |
47 |
Correct |
247 ms |
31864 KB |
Output is correct |
48 |
Correct |
271 ms |
31864 KB |
Output is correct |
49 |
Correct |
248 ms |
31864 KB |
Output is correct |
50 |
Correct |
254 ms |
31736 KB |
Output is correct |
51 |
Correct |
261 ms |
31864 KB |
Output is correct |
52 |
Correct |
266 ms |
31864 KB |
Output is correct |
53 |
Correct |
258 ms |
31868 KB |
Output is correct |
54 |
Correct |
293 ms |
31864 KB |
Output is correct |
55 |
Correct |
305 ms |
31992 KB |
Output is correct |
56 |
Correct |
261 ms |
31836 KB |
Output is correct |
57 |
Correct |
246 ms |
31992 KB |
Output is correct |
58 |
Correct |
255 ms |
31736 KB |
Output is correct |
59 |
Correct |
267 ms |
31736 KB |
Output is correct |
60 |
Correct |
304 ms |
31992 KB |
Output is correct |
61 |
Correct |
283 ms |
31740 KB |
Output is correct |
62 |
Correct |
272 ms |
31964 KB |
Output is correct |
63 |
Correct |
276 ms |
31868 KB |
Output is correct |
64 |
Correct |
261 ms |
31736 KB |
Output is correct |
65 |
Correct |
296 ms |
31992 KB |
Output is correct |
66 |
Correct |
249 ms |
31864 KB |
Output is correct |
67 |
Correct |
248 ms |
31864 KB |
Output is correct |
68 |
Correct |
347 ms |
31864 KB |
Output is correct |
69 |
Correct |
266 ms |
31992 KB |
Output is correct |
70 |
Correct |
333 ms |
31864 KB |
Output is correct |
71 |
Correct |
327 ms |
31864 KB |
Output is correct |
72 |
Correct |
274 ms |
31864 KB |
Output is correct |
73 |
Correct |
265 ms |
31992 KB |
Output is correct |
74 |
Correct |
264 ms |
31864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
237 ms |
31736 KB |
Output is correct |
2 |
Correct |
236 ms |
31864 KB |
Output is correct |
3 |
Correct |
233 ms |
31864 KB |
Output is correct |
4 |
Correct |
236 ms |
31840 KB |
Output is correct |
5 |
Correct |
234 ms |
31736 KB |
Output is correct |
6 |
Correct |
272 ms |
31964 KB |
Output is correct |
7 |
Correct |
236 ms |
31864 KB |
Output is correct |
8 |
Correct |
241 ms |
31832 KB |
Output is correct |
9 |
Correct |
238 ms |
31736 KB |
Output is correct |
10 |
Correct |
221 ms |
31736 KB |
Output is correct |
11 |
Correct |
230 ms |
31736 KB |
Output is correct |
12 |
Correct |
237 ms |
31864 KB |
Output is correct |
13 |
Correct |
219 ms |
31864 KB |
Output is correct |
14 |
Correct |
236 ms |
31832 KB |
Output is correct |
15 |
Correct |
247 ms |
31864 KB |
Output is correct |
16 |
Correct |
232 ms |
31836 KB |
Output is correct |
17 |
Correct |
229 ms |
31864 KB |
Output is correct |
18 |
Correct |
231 ms |
31864 KB |
Output is correct |
19 |
Correct |
245 ms |
31840 KB |
Output is correct |
20 |
Correct |
224 ms |
31736 KB |
Output is correct |
21 |
Correct |
290 ms |
31840 KB |
Output is correct |
22 |
Correct |
327 ms |
31964 KB |
Output is correct |
23 |
Correct |
283 ms |
31864 KB |
Output is correct |
24 |
Correct |
240 ms |
31864 KB |
Output is correct |
25 |
Correct |
223 ms |
31864 KB |
Output is correct |
26 |
Correct |
230 ms |
31868 KB |
Output is correct |
27 |
Correct |
232 ms |
31992 KB |
Output is correct |
28 |
Correct |
251 ms |
31964 KB |
Output is correct |
29 |
Correct |
233 ms |
31864 KB |
Output is correct |
30 |
Correct |
275 ms |
31864 KB |
Output is correct |
31 |
Correct |
245 ms |
31736 KB |
Output is correct |
32 |
Correct |
244 ms |
31736 KB |
Output is correct |
33 |
Correct |
249 ms |
31992 KB |
Output is correct |
34 |
Correct |
242 ms |
31992 KB |
Output is correct |
35 |
Correct |
233 ms |
31864 KB |
Output is correct |
36 |
Correct |
235 ms |
31840 KB |
Output is correct |
37 |
Correct |
253 ms |
31736 KB |
Output is correct |
38 |
Correct |
267 ms |
31832 KB |
Output is correct |
39 |
Correct |
265 ms |
31872 KB |
Output is correct |
40 |
Correct |
246 ms |
31736 KB |
Output is correct |
41 |
Correct |
262 ms |
31964 KB |
Output is correct |
42 |
Correct |
266 ms |
31864 KB |
Output is correct |
43 |
Correct |
250 ms |
31736 KB |
Output is correct |
44 |
Correct |
254 ms |
31872 KB |
Output is correct |
45 |
Correct |
256 ms |
31864 KB |
Output is correct |
46 |
Correct |
277 ms |
31864 KB |
Output is correct |
47 |
Correct |
345 ms |
31736 KB |
Output is correct |
48 |
Correct |
242 ms |
31736 KB |
Output is correct |
49 |
Correct |
277 ms |
31868 KB |
Output is correct |
50 |
Correct |
282 ms |
31736 KB |
Output is correct |
51 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |