Submission #106366

#TimeUsernameProblemLanguageResultExecution timeMemory
106366HideoBali Sculptures (APIO15_sculpture)C++14
0 / 100
637 ms263168 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >

const int N = 107;
const int INF = 1e9 + 7;

ll dp[N][N], pr[N], x[N], ans;
int n, a, b;

vii v[N];

main(){
    ans = INF;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++){
        scanf("%d", &x[i]);
        pr[i] = pr[i - 1] + x[i];
    }
    for (int i = 1; i < N; i++)
        for (int j = 0; j < N; j++)
            dp[i][j] = INF;
    v[0].pb(mk(0, 0));
    for (int i = 1; i <= n; i++){
        for (int g = 1; g <= min(i, b); g++){
            for (pi to : v[g - 1]){
                v[g].pb(mk((to.fr | (pr[i] - pr[to.sc])), i));
                dp[i][g] = min(dp[i][g], (to.fr | (pr[i] - pr[to.sc])));
            }
        }
    }
    for (int i = a; i <= b; i++)
        ans = min(ans, dp[n][i]);
    cout << ans;
}

Compilation message (stderr)

sculpture.cpp:23:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:27:26: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
         scanf("%d", &x[i]);
                     ~~~~~^
sculpture.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...