#include <bits/stdc++.h>
using namespace std;
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
LLI sum[2001];
int dp[2001][2001];
int main() {
int i;
int N,A,B;
scanf("%d %d %d",&N,&A,&B);
for (i = 1; i <= N; i++) scanf("%lld",&sum[i]),sum[i] += sum[i-1];
int j,k,b;
LLI ans = (1LL << 41) - 1;
for (b = 40; b >= 0; b--) {
ans ^= (1LL << b);
fill(dp[0],dp[0]+A+1,MAX_VAL);
dp[0][0] = 0;
for (i = 1; i <= N; i++) {
for (j = 0; j <= A; j++) {
dp[i][j] = MAX_VAL;
for (k = 0; k < i; k++) {
if (!(~ans & (sum[i]-sum[k]))) dp[i][j] = min(dp[i][j],dp[k][(j > 0) ? (j-1):0]+1);
}
}
}
if (dp[N][A] > B) ans ^= (1LL << b);
}
printf("%lld\n",ans);
return 0;
}
Compilation message
sculpture.cpp: In function 'int main()':
sculpture.cpp:49:10: 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:50:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for (i = 1; i <= N; i++) scanf("%lld",&sum[i]),sum[i] += sum[i-1];
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
3 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
5 |
Correct |
2 ms |
800 KB |
Output is correct |
6 |
Correct |
2 ms |
800 KB |
Output is correct |
7 |
Correct |
2 ms |
816 KB |
Output is correct |
8 |
Correct |
2 ms |
816 KB |
Output is correct |
9 |
Correct |
2 ms |
816 KB |
Output is correct |
10 |
Correct |
2 ms |
816 KB |
Output is correct |
11 |
Correct |
2 ms |
816 KB |
Output is correct |
12 |
Correct |
2 ms |
816 KB |
Output is correct |
13 |
Correct |
2 ms |
816 KB |
Output is correct |
14 |
Correct |
2 ms |
816 KB |
Output is correct |
15 |
Correct |
2 ms |
880 KB |
Output is correct |
16 |
Correct |
2 ms |
880 KB |
Output is correct |
17 |
Correct |
2 ms |
968 KB |
Output is correct |
18 |
Correct |
2 ms |
968 KB |
Output is correct |
19 |
Correct |
2 ms |
968 KB |
Output is correct |
20 |
Correct |
2 ms |
968 KB |
Output is correct |
21 |
Correct |
2 ms |
968 KB |
Output is correct |
22 |
Correct |
2 ms |
968 KB |
Output is correct |
23 |
Correct |
2 ms |
968 KB |
Output is correct |
24 |
Correct |
3 ms |
968 KB |
Output is correct |
25 |
Correct |
2 ms |
968 KB |
Output is correct |
26 |
Correct |
2 ms |
968 KB |
Output is correct |
27 |
Correct |
2 ms |
968 KB |
Output is correct |
28 |
Correct |
2 ms |
968 KB |
Output is correct |
29 |
Correct |
2 ms |
968 KB |
Output is correct |
30 |
Correct |
2 ms |
968 KB |
Output is correct |
31 |
Correct |
2 ms |
968 KB |
Output is correct |
32 |
Correct |
2 ms |
968 KB |
Output is correct |
33 |
Correct |
2 ms |
968 KB |
Output is correct |
34 |
Correct |
2 ms |
968 KB |
Output is correct |
35 |
Correct |
2 ms |
968 KB |
Output is correct |
36 |
Correct |
2 ms |
968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
968 KB |
Output is correct |
2 |
Correct |
2 ms |
968 KB |
Output is correct |
3 |
Correct |
2 ms |
968 KB |
Output is correct |
4 |
Correct |
2 ms |
968 KB |
Output is correct |
5 |
Correct |
2 ms |
968 KB |
Output is correct |
6 |
Correct |
2 ms |
968 KB |
Output is correct |
7 |
Correct |
2 ms |
968 KB |
Output is correct |
8 |
Correct |
2 ms |
968 KB |
Output is correct |
9 |
Correct |
2 ms |
968 KB |
Output is correct |
10 |
Correct |
2 ms |
968 KB |
Output is correct |
11 |
Correct |
2 ms |
968 KB |
Output is correct |
12 |
Correct |
2 ms |
968 KB |
Output is correct |
13 |
Correct |
2 ms |
972 KB |
Output is correct |
14 |
Correct |
2 ms |
976 KB |
Output is correct |
15 |
Correct |
2 ms |
1080 KB |
Output is correct |
16 |
Correct |
2 ms |
1080 KB |
Output is correct |
17 |
Correct |
2 ms |
1080 KB |
Output is correct |
18 |
Correct |
2 ms |
1080 KB |
Output is correct |
19 |
Correct |
2 ms |
1080 KB |
Output is correct |
20 |
Correct |
3 ms |
1080 KB |
Output is correct |
21 |
Correct |
2 ms |
1080 KB |
Output is correct |
22 |
Correct |
2 ms |
1080 KB |
Output is correct |
23 |
Correct |
2 ms |
1080 KB |
Output is correct |
24 |
Correct |
2 ms |
1148 KB |
Output is correct |
25 |
Correct |
2 ms |
1148 KB |
Output is correct |
26 |
Correct |
2 ms |
1196 KB |
Output is correct |
27 |
Correct |
2 ms |
1196 KB |
Output is correct |
28 |
Correct |
2 ms |
1272 KB |
Output is correct |
29 |
Correct |
2 ms |
1272 KB |
Output is correct |
30 |
Correct |
2 ms |
1280 KB |
Output is correct |
31 |
Correct |
2 ms |
1280 KB |
Output is correct |
32 |
Correct |
3 ms |
1280 KB |
Output is correct |
33 |
Correct |
2 ms |
1284 KB |
Output is correct |
34 |
Correct |
2 ms |
1332 KB |
Output is correct |
35 |
Correct |
2 ms |
1332 KB |
Output is correct |
36 |
Correct |
2 ms |
1332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1332 KB |
Output is correct |
2 |
Correct |
2 ms |
1332 KB |
Output is correct |
3 |
Correct |
2 ms |
1332 KB |
Output is correct |
4 |
Correct |
2 ms |
1332 KB |
Output is correct |
5 |
Correct |
2 ms |
1332 KB |
Output is correct |
6 |
Correct |
2 ms |
1332 KB |
Output is correct |
7 |
Correct |
2 ms |
1372 KB |
Output is correct |
8 |
Correct |
2 ms |
1372 KB |
Output is correct |
9 |
Correct |
2 ms |
1372 KB |
Output is correct |
10 |
Correct |
2 ms |
1372 KB |
Output is correct |
11 |
Correct |
3 ms |
1372 KB |
Output is correct |
12 |
Correct |
2 ms |
1372 KB |
Output is correct |
13 |
Correct |
2 ms |
1372 KB |
Output is correct |
14 |
Correct |
3 ms |
1372 KB |
Output is correct |
15 |
Correct |
3 ms |
1448 KB |
Output is correct |
16 |
Correct |
3 ms |
1476 KB |
Output is correct |
17 |
Correct |
3 ms |
1508 KB |
Output is correct |
18 |
Correct |
2 ms |
1508 KB |
Output is correct |
19 |
Correct |
3 ms |
1516 KB |
Output is correct |
20 |
Correct |
3 ms |
1520 KB |
Output is correct |
21 |
Correct |
3 ms |
1524 KB |
Output is correct |
22 |
Correct |
2 ms |
1564 KB |
Output is correct |
23 |
Correct |
2 ms |
1568 KB |
Output is correct |
24 |
Correct |
2 ms |
1612 KB |
Output is correct |
25 |
Correct |
3 ms |
1656 KB |
Output is correct |
26 |
Correct |
4 ms |
1772 KB |
Output is correct |
27 |
Correct |
4 ms |
1772 KB |
Output is correct |
28 |
Correct |
4 ms |
1808 KB |
Output is correct |
29 |
Correct |
5 ms |
1912 KB |
Output is correct |
30 |
Correct |
4 ms |
1912 KB |
Output is correct |
31 |
Correct |
3 ms |
1912 KB |
Output is correct |
32 |
Correct |
4 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1912 KB |
Output is correct |
2 |
Correct |
2 ms |
1912 KB |
Output is correct |
3 |
Correct |
2 ms |
1912 KB |
Output is correct |
4 |
Correct |
2 ms |
1912 KB |
Output is correct |
5 |
Correct |
2 ms |
1912 KB |
Output is correct |
6 |
Correct |
2 ms |
1912 KB |
Output is correct |
7 |
Correct |
3 ms |
1912 KB |
Output is correct |
8 |
Correct |
3 ms |
1912 KB |
Output is correct |
9 |
Correct |
2 ms |
1912 KB |
Output is correct |
10 |
Correct |
2 ms |
1912 KB |
Output is correct |
11 |
Correct |
2 ms |
1912 KB |
Output is correct |
12 |
Correct |
3 ms |
1912 KB |
Output is correct |
13 |
Correct |
2 ms |
1912 KB |
Output is correct |
14 |
Correct |
2 ms |
1912 KB |
Output is correct |
15 |
Correct |
3 ms |
1912 KB |
Output is correct |
16 |
Correct |
2 ms |
1912 KB |
Output is correct |
17 |
Correct |
3 ms |
1912 KB |
Output is correct |
18 |
Correct |
3 ms |
1912 KB |
Output is correct |
19 |
Correct |
2 ms |
1912 KB |
Output is correct |
20 |
Correct |
2 ms |
1912 KB |
Output is correct |
21 |
Correct |
2 ms |
1912 KB |
Output is correct |
22 |
Correct |
2 ms |
1912 KB |
Output is correct |
23 |
Correct |
2 ms |
1912 KB |
Output is correct |
24 |
Correct |
2 ms |
1912 KB |
Output is correct |
25 |
Correct |
2 ms |
1912 KB |
Output is correct |
26 |
Correct |
2 ms |
1912 KB |
Output is correct |
27 |
Correct |
2 ms |
1912 KB |
Output is correct |
28 |
Correct |
2 ms |
1912 KB |
Output is correct |
29 |
Correct |
2 ms |
1912 KB |
Output is correct |
30 |
Correct |
3 ms |
1912 KB |
Output is correct |
31 |
Correct |
2 ms |
1912 KB |
Output is correct |
32 |
Correct |
2 ms |
1912 KB |
Output is correct |
33 |
Correct |
2 ms |
1912 KB |
Output is correct |
34 |
Correct |
2 ms |
1912 KB |
Output is correct |
35 |
Correct |
2 ms |
1912 KB |
Output is correct |
36 |
Correct |
2 ms |
1912 KB |
Output is correct |
37 |
Correct |
2 ms |
1912 KB |
Output is correct |
38 |
Correct |
2 ms |
1912 KB |
Output is correct |
39 |
Correct |
2 ms |
1912 KB |
Output is correct |
40 |
Correct |
2 ms |
1912 KB |
Output is correct |
41 |
Correct |
3 ms |
1912 KB |
Output is correct |
42 |
Correct |
3 ms |
1912 KB |
Output is correct |
43 |
Correct |
3 ms |
1912 KB |
Output is correct |
44 |
Correct |
2 ms |
1912 KB |
Output is correct |
45 |
Correct |
2 ms |
1912 KB |
Output is correct |
46 |
Correct |
4 ms |
1912 KB |
Output is correct |
47 |
Correct |
4 ms |
1912 KB |
Output is correct |
48 |
Correct |
3 ms |
1936 KB |
Output is correct |
49 |
Correct |
4 ms |
2060 KB |
Output is correct |
50 |
Correct |
4 ms |
2092 KB |
Output is correct |
51 |
Correct |
5 ms |
2100 KB |
Output is correct |
52 |
Correct |
4 ms |
2104 KB |
Output is correct |
53 |
Correct |
4 ms |
2112 KB |
Output is correct |
54 |
Correct |
5 ms |
2112 KB |
Output is correct |
55 |
Correct |
4 ms |
2116 KB |
Output is correct |
56 |
Correct |
4 ms |
2116 KB |
Output is correct |
57 |
Correct |
4 ms |
2116 KB |
Output is correct |
58 |
Correct |
4 ms |
2116 KB |
Output is correct |
59 |
Correct |
3 ms |
2132 KB |
Output is correct |
60 |
Correct |
3 ms |
2136 KB |
Output is correct |
61 |
Correct |
3 ms |
2136 KB |
Output is correct |
62 |
Correct |
3 ms |
2144 KB |
Output is correct |
63 |
Correct |
3 ms |
2276 KB |
Output is correct |
64 |
Correct |
24 ms |
2276 KB |
Output is correct |
65 |
Correct |
4 ms |
2276 KB |
Output is correct |
66 |
Correct |
4 ms |
2276 KB |
Output is correct |
67 |
Correct |
4 ms |
2276 KB |
Output is correct |
68 |
Correct |
7 ms |
2276 KB |
Output is correct |
69 |
Correct |
24 ms |
2276 KB |
Output is correct |
70 |
Correct |
20 ms |
2276 KB |
Output is correct |
71 |
Correct |
4 ms |
2276 KB |
Output is correct |
72 |
Correct |
4 ms |
2276 KB |
Output is correct |
73 |
Correct |
18 ms |
2276 KB |
Output is correct |
74 |
Correct |
14 ms |
2276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2276 KB |
Output is correct |
2 |
Correct |
2 ms |
2276 KB |
Output is correct |
3 |
Correct |
2 ms |
2276 KB |
Output is correct |
4 |
Correct |
2 ms |
2276 KB |
Output is correct |
5 |
Correct |
2 ms |
2276 KB |
Output is correct |
6 |
Correct |
2 ms |
2276 KB |
Output is correct |
7 |
Correct |
2 ms |
2276 KB |
Output is correct |
8 |
Correct |
2 ms |
2276 KB |
Output is correct |
9 |
Correct |
2 ms |
2276 KB |
Output is correct |
10 |
Correct |
2 ms |
2276 KB |
Output is correct |
11 |
Correct |
2 ms |
2276 KB |
Output is correct |
12 |
Correct |
2 ms |
2276 KB |
Output is correct |
13 |
Correct |
2 ms |
2276 KB |
Output is correct |
14 |
Correct |
2 ms |
2276 KB |
Output is correct |
15 |
Correct |
3 ms |
2276 KB |
Output is correct |
16 |
Correct |
2 ms |
2276 KB |
Output is correct |
17 |
Correct |
2 ms |
2276 KB |
Output is correct |
18 |
Correct |
2 ms |
2276 KB |
Output is correct |
19 |
Correct |
2 ms |
2276 KB |
Output is correct |
20 |
Correct |
3 ms |
2276 KB |
Output is correct |
21 |
Correct |
3 ms |
2276 KB |
Output is correct |
22 |
Correct |
3 ms |
2276 KB |
Output is correct |
23 |
Correct |
3 ms |
2276 KB |
Output is correct |
24 |
Correct |
2 ms |
2276 KB |
Output is correct |
25 |
Correct |
2 ms |
2276 KB |
Output is correct |
26 |
Correct |
2 ms |
2276 KB |
Output is correct |
27 |
Correct |
2 ms |
2276 KB |
Output is correct |
28 |
Correct |
3 ms |
2276 KB |
Output is correct |
29 |
Correct |
3 ms |
2276 KB |
Output is correct |
30 |
Correct |
3 ms |
2276 KB |
Output is correct |
31 |
Correct |
3 ms |
2276 KB |
Output is correct |
32 |
Correct |
3 ms |
2276 KB |
Output is correct |
33 |
Correct |
2 ms |
2276 KB |
Output is correct |
34 |
Correct |
3 ms |
2276 KB |
Output is correct |
35 |
Correct |
3 ms |
2276 KB |
Output is correct |
36 |
Correct |
3 ms |
2276 KB |
Output is correct |
37 |
Correct |
3 ms |
2276 KB |
Output is correct |
38 |
Correct |
4 ms |
2396 KB |
Output is correct |
39 |
Correct |
4 ms |
2396 KB |
Output is correct |
40 |
Correct |
4 ms |
2400 KB |
Output is correct |
41 |
Correct |
4 ms |
2408 KB |
Output is correct |
42 |
Correct |
4 ms |
2408 KB |
Output is correct |
43 |
Correct |
3 ms |
2408 KB |
Output is correct |
44 |
Correct |
3 ms |
2408 KB |
Output is correct |
45 |
Correct |
3 ms |
2408 KB |
Output is correct |
46 |
Correct |
3 ms |
2428 KB |
Output is correct |
47 |
Correct |
3 ms |
2428 KB |
Output is correct |
48 |
Correct |
3 ms |
2428 KB |
Output is correct |
49 |
Correct |
4 ms |
2472 KB |
Output is correct |
50 |
Correct |
3 ms |
2472 KB |
Output is correct |
51 |
Correct |
3 ms |
2472 KB |
Output is correct |
52 |
Correct |
21 ms |
4456 KB |
Output is correct |
53 |
Correct |
36 ms |
5108 KB |
Output is correct |
54 |
Correct |
58 ms |
6224 KB |
Output is correct |
55 |
Correct |
54 ms |
6224 KB |
Output is correct |
56 |
Correct |
191 ms |
10232 KB |
Output is correct |
57 |
Correct |
220 ms |
10256 KB |
Output is correct |
58 |
Correct |
187 ms |
10272 KB |
Output is correct |
59 |
Correct |
206 ms |
10328 KB |
Output is correct |
60 |
Correct |
208 ms |
10348 KB |
Output is correct |
61 |
Correct |
3 ms |
10348 KB |
Output is correct |
62 |
Correct |
32 ms |
10348 KB |
Output is correct |
63 |
Correct |
56 ms |
10348 KB |
Output is correct |
64 |
Correct |
53 ms |
10348 KB |
Output is correct |
65 |
Correct |
95 ms |
10348 KB |
Output is correct |
66 |
Correct |
141 ms |
10348 KB |
Output is correct |
67 |
Correct |
184 ms |
10348 KB |
Output is correct |
68 |
Correct |
196 ms |
10468 KB |
Output is correct |
69 |
Correct |
190 ms |
10488 KB |
Output is correct |