Submission #551314

# Submission time Handle Problem Language Result Execution time Memory
551314 2022-04-20T09:11:39 Z radaiosm7 Bali Sculptures (APIO15_sculpture) C++
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
int n, a, b, i, j, k;
long long pref[2005];
long long ar[2005];
long long dp[2005][2005];
long long ans;

int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (i=1; i <= n; ++i) scanf("%lld", &ar[i]);
  pref[0] = 0LL;
  for (i=1; i <= n; ++i) pref[i] = pref[i-1]+ar[i];

  for (i=0; i <= b; ++i) dp[0][i] = 0;

  for (i=2; i <= n; ++i) {
    dp[i][1] = pref[i];

    for (j=2; j <= b; ++j) {
      dp[i][j] = INT_MAX;
      for (k=i-1; k >= 0; --k) dp[i][j] = min(dp[i][j], dp[k][j-1]|(pref[i]-pref[k]));
    }
  }

  ans = INT_MAX;
  for (i=a; i <= b; ++i) ans = min(ans, dp[n][i]);
  printf("%lld\n", ans);
  return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d%d%d", &n, &a, &b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   for (i=1; i <= n; ++i) scanf("%lld", &ar[i]);
      |                          ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 292 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -