This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |