Submission #551059

# Submission time Handle Problem Language Result Execution time Memory
551059 2022-04-19T18:19:46 Z ala2 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
79 ms 170028 KB
#include <bits/stdc++.h>
    #define int long long
    #define pb push_back
    #define F first
    #define S second
    #define B begin()
    #define E end()
    using namespace std;
    int n,l,r;
    int a[1001000];
    int p[1000100];
    int suf[1001000];
    int dp[104][104][2004];
    int sum(int i,int j)
    {
        return p[j]-p[i]+a[i];
    }
    int f(int i,int k,int x)
    {
        if(k==r)
        {
            return (x|suf[i]);
        }
        if(i==n-1)
            return (x|a[i]);
        if(dp[i][k][x]!=-1)
            return dp[i][k][x];
        int mn=1e17;
        if(k>=l)
            mn=min(mn,(suf[i]|x));
        for(int j=i;j<n-1;j++)
        {
            mn=min(mn,f(j+1,k+1,(x|sum(i,j))));

        }
        return dp[i][k][x]=mn;

    }
    signed main()
    {
         memset(dp,-1,sizeof dp);
        cin>>n>>l>>r;
        l--;
        r--;
        for(int i=0;i<n;i++)
            cin>>a[i];
        p[0]=a[0];
        for(int i=1;i<n;i++)
            p[i]=p[i-1]+a[i];
        suf[n-1]=a[n-1];
        for(int i=n-2;i>=0;i--)
        {
            suf[i]=suf[i+1]+a[i];
        }
      
        int rr=r;
        int mn=1e18;
        for(int i=l;i<=rr;i++)
        {
            r=i;
        mn=min(mn,f(0,0,0));

        }
          int c=f(0,0,0);
        cout<<mn<<endl;
    }

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:64:15: warning: unused variable 'c' [-Wunused-variable]
   64 |           int c=f(0,0,0);
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 62 ms 169936 KB Output is correct
2 Incorrect 65 ms 169884 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 170028 KB Output is correct
2 Incorrect 68 ms 169928 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 169932 KB Output is correct
2 Incorrect 61 ms 169932 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 67 ms 169848 KB Output is correct
2 Incorrect 73 ms 169956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 169932 KB Output is correct
2 Incorrect 63 ms 169928 KB Output isn't correct
3 Halted 0 ms 0 KB -