Submission #634099

# Submission time Handle Problem Language Result Execution time Memory
634099 2022-08-23T19:53:29 Z tvladm2009 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
53 ms 95444 KB
#include <iostream>
#include <vector>
#define int long long

using namespace std;

const int MAX_N = 2 * 1e3;
const int INF = (1LL << 60);
const int MAX_L = 11;
int y[MAX_N + 1], range[MAX_N + 1][MAX_N + 1];
vector<int> dp[MAX_N + 1][MAX_N + 1];
int n, a, b;

signed main() {
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        cin >> y[i];
        range[i][i] = y[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            range[i][j] = range[i][j - 1] + y[j];
        }
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i][j].push_back(INF);
        }
    }
    dp[0][0].push_back(0);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= i; k++) {
                for (int l = 0; l < dp[k - 1][j - 1].size(); l++) {
                    if (l > 200) {
                        break;
                    }
                    dp[i][j].push_back(dp[k - 1][j - 1][l] | range[k][i]);
                }
            }
        }
    }
    int answer = INF;
    for (int i = a; i <= b; i++) {
        for (int it : dp[n][i]) {
            answer = min(answer, it);
        }
    }
    cout << answer;
    return 0;
}
/*
20 1 3
9 9 8 8 10 8 8 8 8 9 9 8 8 8 9 8 10 8 9 8


*/

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:34:35: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 for (int l = 0; l < dp[k - 1][j - 1].size(); l++) {
      |                                 ~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 46 ms 94284 KB Output is correct
2 Correct 43 ms 94284 KB Output is correct
3 Correct 43 ms 94256 KB Output is correct
4 Correct 43 ms 94240 KB Output is correct
5 Correct 42 ms 94480 KB Output is correct
6 Incorrect 44 ms 95360 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 94356 KB Output is correct
2 Correct 43 ms 94284 KB Output is correct
3 Correct 44 ms 94256 KB Output is correct
4 Correct 43 ms 94304 KB Output is correct
5 Correct 43 ms 94388 KB Output is correct
6 Incorrect 43 ms 95356 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 45 ms 94236 KB Output is correct
2 Correct 44 ms 94300 KB Output is correct
3 Correct 45 ms 94284 KB Output is correct
4 Correct 45 ms 94244 KB Output is correct
5 Correct 44 ms 94480 KB Output is correct
6 Incorrect 46 ms 95388 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 94336 KB Output is correct
2 Correct 52 ms 94284 KB Output is correct
3 Correct 53 ms 94328 KB Output is correct
4 Correct 45 ms 94284 KB Output is correct
5 Correct 42 ms 94412 KB Output is correct
6 Incorrect 42 ms 95444 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 42 ms 94256 KB Output is correct
2 Correct 45 ms 94364 KB Output is correct
3 Correct 43 ms 94280 KB Output is correct
4 Correct 42 ms 94292 KB Output is correct
5 Correct 44 ms 94472 KB Output is correct
6 Incorrect 45 ms 95364 KB Output isn't correct
7 Halted 0 ms 0 KB -