Submission #404556

# Submission time Handle Problem Language Result Execution time Memory
404556 2021-05-14T15:33:03 Z teehandsome Bali Sculptures (APIO15_sculpture) C++11
0 / 100
1000 ms 2160 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;

template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}

void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
    _print(H);
    if(sizeof...(T)) cerr<<",";
    else cerr<<"\"]";
    dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxn=101;
const int mxg=101;
const int mxv=2001;
int n,a,b;
bool dp[mxn][mxg][mxv];
ll sum[mxn];
vector<int> ar;

ll f(int l,int r) {
    if(!l) return sum[r];
    return sum[r]-sum[l-1];
}



int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>a>>b;
    ar.resize(n);
    for(int i=0;i<n;i++) cin>>ar[i];

    for(int i=0;i<n;i++) {
        sum[i]=ar[i];
        if(i) sum[i]+=sum[i-1];
        dp[i][1][sum[i]]=true;
    }
    for(int i=1;i<n;i++) {
        for(int g=2;g<=i+1;g++) {
            for(int k=0;k<=sum[i];k++) {
                for(int j=i-1;j>=0;j--) {
                    for(int val=0;val<=sum[j];val++) {
                        if(dp[j][g-1][val] and (val|f(j+1,i))==k) {
//                            debug(val,f(j+1,i),val|f(j+1,i),k);
                            dp[i][g][k]=true; goto newK;
                        }
                    }
                }
                newK:;
            }
        }
    }
    ll ans=1e16;
    for(int i=a;i<=b;i++) {
        for(ll j=0;j<=sum[n-1];j++) {
            if(dp[n-1][i][j]) {
                ans=min(ans,j);
                break;
            }
        }
    }

    cout<<ans<<endl;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 9 ms 644 KB Output is correct
8 Correct 10 ms 716 KB Output is correct
9 Correct 33 ms 716 KB Output is correct
10 Correct 41 ms 708 KB Output is correct
11 Correct 41 ms 708 KB Output is correct
12 Correct 8 ms 708 KB Output is correct
13 Correct 7 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 408 KB Output is correct
19 Correct 5 ms 588 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 14 ms 716 KB Output is correct
22 Correct 38 ms 708 KB Output is correct
23 Correct 41 ms 728 KB Output is correct
24 Correct 41 ms 752 KB Output is correct
25 Correct 6 ms 748 KB Output is correct
26 Correct 10 ms 716 KB Output is correct
27 Runtime error 2 ms 332 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 448 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 9 ms 588 KB Output is correct
8 Correct 9 ms 716 KB Output is correct
9 Correct 37 ms 716 KB Output is correct
10 Correct 44 ms 688 KB Output is correct
11 Correct 48 ms 736 KB Output is correct
12 Correct 8 ms 716 KB Output is correct
13 Correct 7 ms 680 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 5 ms 460 KB Output is correct
20 Correct 10 ms 588 KB Output is correct
21 Correct 15 ms 744 KB Output is correct
22 Correct 38 ms 644 KB Output is correct
23 Correct 41 ms 708 KB Output is correct
24 Correct 41 ms 676 KB Output is correct
25 Correct 6 ms 716 KB Output is correct
26 Correct 10 ms 716 KB Output is correct
27 Correct 16 ms 792 KB Output is correct
28 Correct 44 ms 944 KB Output is correct
29 Correct 384 ms 1860 KB Output is correct
30 Correct 389 ms 2136 KB Output is correct
31 Execution timed out 1085 ms 1864 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 3 ms 588 KB Output is correct
7 Correct 9 ms 640 KB Output is correct
8 Correct 11 ms 708 KB Output is correct
9 Correct 34 ms 648 KB Output is correct
10 Correct 55 ms 672 KB Output is correct
11 Correct 41 ms 720 KB Output is correct
12 Correct 8 ms 712 KB Output is correct
13 Correct 8 ms 716 KB Output is correct
14 Correct 16 ms 792 KB Output is correct
15 Correct 44 ms 964 KB Output is correct
16 Correct 397 ms 1748 KB Output is correct
17 Correct 396 ms 2160 KB Output is correct
18 Execution timed out 1088 ms 1980 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 9 ms 588 KB Output is correct
8 Correct 8 ms 716 KB Output is correct
9 Correct 33 ms 652 KB Output is correct
10 Correct 41 ms 728 KB Output is correct
11 Correct 41 ms 708 KB Output is correct
12 Correct 8 ms 716 KB Output is correct
13 Correct 7 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 6 ms 588 KB Output is correct
20 Correct 11 ms 640 KB Output is correct
21 Correct 15 ms 716 KB Output is correct
22 Correct 38 ms 704 KB Output is correct
23 Correct 42 ms 708 KB Output is correct
24 Correct 48 ms 712 KB Output is correct
25 Correct 6 ms 716 KB Output is correct
26 Correct 10 ms 764 KB Output is correct
27 Runtime error 2 ms 460 KB Execution killed with signal 11
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 9 ms 604 KB Output is correct
8 Correct 9 ms 716 KB Output is correct
9 Correct 33 ms 704 KB Output is correct
10 Correct 45 ms 648 KB Output is correct
11 Correct 54 ms 676 KB Output is correct
12 Correct 8 ms 716 KB Output is correct
13 Correct 10 ms 692 KB Output is correct
14 Runtime error 2 ms 332 KB Execution killed with signal 11
15 Halted 0 ms 0 KB -