답안 #551317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
551317 2022-04-20T09:19:53 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] = INT_MAX;

  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 > j; --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]);
      |                          ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -