Submission #566491

# Submission time Handle Problem Language Result Execution time Memory
566491 2022-05-22T11:08:09 Z ac2hu Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else 
#define deb(x...)
#endif
using namespace std;
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n, a, b;cin >> n >> a >> b;
    vector<int> Y(n);
    for(auto &e : Y)cin >> e;
    vector<int> dp[n + 1][n + 1];
    dp[0][0] = {0};
    auto get_best = [&](vector<int> &tt, int temp){
        int val = 1e9;
        for(int e : tt){
            if((e|temp) < (temp|val)){
                val = e;
            }
        }
        return val;
    };
    for(int i = 1;i<=n;i++){
        for(int gsize = 1;gsize<=n;gsize++){
            int tsum = 0;
            for(int j = i;j>=1;j--){
                tsum += Y[j - 1];
                if(dp[j - 1][gsize - 1].size() != 0){
                    int gbe = get_best(dp[j - 1][gsize - 1], tsum);
                    dp[i][gsize].push_back(gbe|tsum);
                }
            }
        }
    }
    int ans = 1e9;
    for(int i = a;i<=b;i++){
        deb(i, dp[n][i]);
        if(dp[n][i].size() != 0)
            ans = min(ans, *min_element(dp[n][i].begin(), dp[n][i].end()));
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 324 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 316 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Incorrect 1 ms 316 KB Output isn't correct
7 Halted 0 ms 0 KB -