Submission #1020143

# Submission time Handle Problem Language Result Execution time Memory
1020143 2024-07-11T15:39:04 Z KasymK Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 444 KB
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(v) v.begin(), v.end()

const int N = 2e3+5;

ll dp[N][N], par[N];

int main(){
    // freopen("file.txt", "r", stdin);
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    for(int i = 0; i <= n; ++i)
        for(int k = 0; k <= n; ++k)
            dp[i][k] = 1e18;
    vector<int> v(n);
    for(int &i : v)
        scanf("%d", &i);
    for(int i = 1; i <= n; ++i)
        par[i] = par[i-1]+v[i-1];
    dp[0][0] = 0;
    for(int i = 1; i <= n; ++i)
        for(int k = 1; k <= b; ++k)
            for(int j = 0; j < i; ++j)
                dp[i][k] = min(dp[i][k], dp[j][k-1]|(par[i]-par[j]));
    ll ans = 1e18;
    for(int k = a; k <= b; ++k)
        ans = min(ans, dp[n][k]);
    printf("%lld", ans);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d%d%d", &n, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", &i);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 444 KB Output isn't correct
3 Halted 0 ms 0 KB -