# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
739477 | 2023-05-10T14:02:08 Z | Username4132 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 340 KB |
#include<iostream> #include<vector> #include<random> #include<algorithm> using namespace std; using ll = long long; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) #define dforn(i, n) for(int i=n-1; i>=0; --i) const int MAXN=2010, INF=1000000000; int n, A, B, arr[MAXN], jump[MAXN][MAXN], dp1[MAXN]; bool test(int bit){ forn(i, n){ ll sum=0; forsn(j, i+1, n+1){ sum+=arr[j-1]; jump[i][j]=((sum|bit)==bit); } } if(A==1){ dp1[n]=0; dforn(i, n){ dp1[i]=INF; forsn(j, i+1, n+1) if(jump[i][j]) dp1[i]=min(dp1[i], dp1[j]+1); } return dp1[0]<=B; } return false; } int main(){ scanf("%d %d %d", &n, &A, &B); forn(i, n) scanf("%d", &arr[i]); ll lo=0, hi=(1LL<<32)-1; while(hi-lo>1){ int mid=(hi+lo)>>1; if(test(mid)) hi=mid; else lo=mid; } cout << hi << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 244 KB | Output is correct |
3 | Incorrect | 1 ms | 312 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 304 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |