Submission #942495

# Submission time Handle Problem Language Result Execution time Memory
942495 2024-03-10T18:14:59 Z artixkrishna Sličice (COCI19_slicice) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 100005;
int dp[506][506];
template <class X, class Y> bool maximize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x + eps < y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class X, class Y> bool minimize(X &x, const Y &y) {
  X eps = 1e-9;
  if (x > y + eps) {
    x = y;
    return 1;
  }
  return 0;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> P(n);
  vector<int> B(m + 1);
  for (auto &i : P)
    cin >> i;
  for (auto &i : B)
    cin >> i;
  for (int i = 1; i <= n; i++) {
    for (int v = 0; v <= k; v++) {
      for (int pre_v = 0; pre_v <= v; pre_v++) {
        maximize(dp[i][v], dp[i - 1][pre_v] + b[a[i] + (v - pre_v)]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; i++) {
    maximize(ans, dp[n][i]);
  }
  cout << ans << endl;
}




Compilation message

slicice.cpp: In function 'int main()':
slicice.cpp:34:47: error: 'b' was not declared in this scope
   34 |         maximize(dp[i][v], dp[i - 1][pre_v] + b[a[i] + (v - pre_v)]);
      |                                               ^
slicice.cpp:34:49: error: 'a' was not declared in this scope
   34 |         maximize(dp[i][v], dp[i - 1][pre_v] + b[a[i] + (v - pre_v)]);
      |                                                 ^